<div dir="ltr">The log output suggests the xf_ cookie check in vcl_recv is not the first thing to run as you pasted earlier. Also, looking a bit closer, your issue the fact that you unset the cookie in vcl_backend_response if it's not wordpress related. Again, you should really audit your entire VCL, and remove unneeded stuff, like all the WordPress related rules if you're not using it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 4, 2016 at 9:43 AM, Ayberk Kimsesiz <span dir="ltr"><<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Log message: <div><br></div><div><div>[root@ns1 ~]# varnishlog | grep -A15 -B15 "PPPAASS"</div><div>- ReqHeader If-None-Match: "1787d-5392dab8f2b4e-gzip"</div><div>- ReqHeader If-Modified-Since: Wed, 03 Aug 2016 16:53:18 GMT</div><div>- ReqHeader X-Forwarded-For: 95.5.187.232</div><div>- VCL_call RECV</div><div>- ReqHeader X-Actual-IP: 95.5.187.232</div><div>- ReqUnset X-Forwarded-For: 95.5.187.232</div><div>- ReqHeader X-Forwarded-For: 95.5.187.232, 95.5.187.232</div><div>- ReqUnset Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; __gads=ID=83a3a88cd0381f62:T=<wbr>1470300206:S=ALNI_MawbfRUla wFoW2XT0IpqCIsH5v7bQ; xf_session=</div><div>- ReqHeader Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; xf_session=<wbr>87bea6639553d44d72f0d612924b52<wbr>ac; wordpress_t est_cookie=WP+Cookie+check</div><div>- ReqUnset Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; xf_session=<wbr>87bea6639553d44d72f0d612924b52<wbr>ac; wordpress_t est_cookie=WP+Cookie+check</div><div>- ReqHeader Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; xf_session=<wbr>87bea6639553d44d72f0d612924b52<wbr>ac; wordpress_t est_cookie=WP+Cookie+check</div><div>- ReqUnset X-Forwarded-For: 95.5.187.232, 95.5.187.232</div><div>- ReqHeader X-Forwarded-For: 95.5.187.232, 95.5.187.232, 95.5.187.232</div><div>- ReqUnset Accept-Encoding: gzip, deflate, sdch</div><div>- ReqHeader Accept-Encoding: gzip</div><div>- VCL_Log PPPAASS</div><div>- VCL_return pass</div><div>- VCL_call HASH</div><div>- VCL_return lookup</div><div>- VCL_call PASS</div><div>- VCL_return fetch</div><div>- Link bereq 524435 pass</div><div>- Timestamp Fetch: 1470321283.617655 0.005758 0.005758</div><div>- RespProtocol HTTP/1.1</div><div>- RespStatus 200</div><div>- RespReason OK</div><div>- RespHeader Date: Thu, 04 Aug 2016 14:34:43 GMT</div><div>- RespHeader Server: Apache/2</div><div>- RespHeader Last-Modified: Wed, 03 Aug 2016 16:53:18 GMT</div><div>- RespHeader ETag: "1787d-5392dab8f2b4e-gzip"</div><div>- RespHeader Accept-Ranges: bytes</div><div>--</div><div>- ReqHeader If-Modified-Since: Thu, 04 Aug 2016 09:32:51 GMT</div><div>- ReqHeader X-Forwarded-For: 95.5.187.232</div><div>- VCL_call RECV</div><div>- ReqHeader X-Actual-IP: 95.5.187.232</div><div>- ReqUnset X-Forwarded-For: 95.5.187.232</div><div>- ReqHeader X-Forwarded-For: 95.5.187.232, 95.5.187.232</div><div>- ReqUnset Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; __gads=ID=83a3a88cd0381f62:T=<wbr>1470300206:S=ALNI_MawbfRUla wFoW2XT0IpqCIsH5v7bQ; xf_session=</div><div>- ReqHeader Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; xf_session=<wbr>87bea6639553d44d72f0d612924b52<wbr>ac; wordpress_t est_cookie=WP+Cookie+check</div><div>- ReqUnset Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th u%20Aug%2004%202016%2010%3A05%<wbr>3A38%20GMT+0300%20%28Turkey%<wbr>20Daylight%20Time%29; pps_times_showed_100=1; xf_session=<wbr>87bea6639553d44d72f0d612924b52<wbr>ac; wordpress_t est_cookie=WP+Cookie+check</div><div>- ReqHeader Cookie: PHPSESSID=<wbr>mvdt2ok0h7qpje8aej6s7hdd73; pps_show_100=Th </div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-08-04 17:24 GMT+03:00 Lane, Richard <span dir="ltr"><<a href="mailto:rlane@ahbelo.com" target="_blank">rlane@ahbelo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I assume you reloaded/restarted Varnish after these changes were made. If so, can you verify that you do have the cookies set on the request?<br><br>maybe add this log message right before returning<span><br><br>if(req.http.Cookie ~ "xf_(session|user)") {<br></span> std.log( "PPPAASS Cookie set for forum");<br> return (pass);<br><br> }<br><br>Then you can use varnishlog command (below) to verify cookie is found<br><br>varnishlog | grep -A15 -B15 "PPPAASS"<div><br></div><div><br></div><div>Cheers,</div><div>Richard<div><div><br><br>On Thu, Aug 4, 2016 at 9:06 AM, Ayberk Kimsesiz <<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>> wrote:<br>><br>> First of all, thank you. However the problem continues. Can you examine the codes?<br>><br>><br>> /* SET THE HOST AND PORT OF WORDPRESS<br>> * ******************************<wbr>***************************/<br>> vcl 4.0;<br>> import std;<br>><br>> backend default {<br>> .host = "*******";<br>> .port = "8080";<br>> .connect_timeout = 600s;<br>> .first_byte_timeout = 600s;<br>> .between_bytes_timeout = 600s;<br>> .max_connections = 800;<br>> }<br>> <br>> # SET THE ALLOWED IP OF PURGE REQUESTS<br>> # ##############################<wbr>############################<br>> acl purge {<br>> "localhost";<br>> "127.0.0.1";<br>> }<br>><br>> #THE RECV FUNCTION<br>> # ##############################<wbr>############################<br>> sub vcl_recv { <br>><br>> if(req.http.Cookie ~ "xf_(session|user)") {<br>> return (pass);<br>> }<br>><br>> # set realIP by trimming CloudFlare IP which will be used for various checks<br>> set req.http.X-Actual-IP = regsub(req.http.X-Forwarded-Fo<wbr>r, "[, ].*$", ""); <br>><br>> # FORWARD THE IP OF THE REQUEST<br>> if (req.restarts == 0) {<br>> if (req.http.x-forwarded-for) {<br>> set req.http.X-Forwarded-For =<br>> req.http.X-Forwarded-For + ", " + client.ip;<br>> } else {<br>> set req.http.X-Forwarded-For = client.ip;<br>> }<br>> }<br>><br>> # Purge request check sections for hash_always_miss, purge and ban<br>> # BLOCK IF NOT IP is not in purge acl<br>> # ##############################<wbr>############################<br>><br>> # Enable smart refreshing using hash_always_miss<br>> if (req.http.Cache-Control ~ "no-cache") {<br>> if (client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~ purge) {<br>> set req.hash_always_miss = true;<br>> }<br>> }<br>><br>> if (req.method == "PURGE") {<br>> if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~ purge) {<br>> return(synth(405,"Not allowed."));<br>> }<br>> return (purge);<br>><br>> }<br>> if (req.method == "BAN") {<br>> # Same ACL check as above:<br>> if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~ purge) {<br>> return(synth(403, "Not allowed."));<br>> }<br>> ban("req.http.host == " + req.http.host +<br>> " && req.url == " + req.url);<br>><br>> # Throw a synthetic page so the<br>> # request won't go to the backend.<br>> return(synth(200, "Ban added"));<br>> }<br>><br>><br>> # Unset cloudflare cookies<br>> # Remove has_js and CloudFlare/Google Analytics __* cookies.<br>> set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;<wbr>]*", "");<br>> # Remove a ";" prefix, if present.<br>> set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");<br>><br>> # For Testing: If you want to test with Varnish passing (not caching) uncomment<br>> # return( pass );<br>><br>> # FORWARD THE IP OF THE REQUEST<br>> if (req.restarts == 0) {<br>> if (req.http.x-forwarded-for) {<br>> set req.http.X-Forwarded-For =<br>> req.http.X-Forwarded-For + ", " + client.ip;<br>> } else {<br>> set req.http.X-Forwarded-For = client.ip;<br>> }<br>> }<br>><br>> # DO NOT CACHE RSS FEED<br>> if (req.url ~ "/feed(/)?") {<br>> return ( pass ); <br>> }<br>><br>> ## Do not cache search results, comment these 3 lines if you do want to cache them<br>><br>> if (req.url ~ "/\?s\=") {<br>> return ( pass ); <br>> }<br>><br>> # CLEAN UP THE ENCODING HEADER.<br>> # SET TO GZIP, DEFLATE, OR REMOVE ENTIRELY. WITH VARY ACCEPT-ENCODING<br>> # VARNISH WILL CREATE SEPARATE CACHES FOR EACH<br>> # DO NOT ACCEPT-ENCODING IMAGES, ZIPPED FILES, AUDIO, ETC.<br>> # ##############################<wbr>############################<br>> if (req.http.Accept-Encoding) {<br>> if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz<wbr>|mp3|ogg)$") {<br>> # No point in compressing these<br>> unset req.http.Accept-Encoding;<br>> } elsif (req.http.Accept-Encoding ~ "gzip") {<br>> set req.http.Accept-Encoding = "gzip";<br>> } elsif (req.http.Accept-Encoding ~ "deflate") {<br>> set req.http.Accept-Encoding = "deflate";<br>> } else {<br>> # unknown algorithm<br>> unset req.http.Accept-Encoding;<br>> }<br>> }<br>><br>> # PIPE ALL NON-STANDARD REQUESTS<br>> # ##############################<wbr>############################<br>> if (req.method != "GET" &&<br>> req.method != "HEAD" &&<br>> req.method != "PUT" && <br>> req.method != "POST" &&<br>> req.method != "TRACE" &&<br>> req.method != "OPTIONS" &&<br>> req.method != "DELETE") {<br>> return (pipe);<br>> }<br>> <br>> # ONLY CACHE GET AND HEAD REQUESTS<br>> # ##############################<wbr>############################<br>> if (req.method != "GET" && req.method != "HEAD") {<br>> return (pass);<br>> }<br>> <br>> # OPTIONAL: DO NOT CACHE LOGGED IN USERS (THIS OCCURS IN FETCH TOO, EITHER<br>> # COMMENT OR UNCOMMENT BOTH<br>> # ##############################<wbr>############################<br>> if ( req.http.cookie ~ "wordpress_logged_in" ) {<br>> return( pass );<br>> }<br>> <br>> # IF THE REQUEST IS NOT FOR A PREVIEW, WP-ADMIN OR WP-LOGIN<br>> # THEN UNSET THE COOKIES<br>> # ##############################<wbr>############################<br>> if (!(req.url ~ "wp-(login|admin)") <br>> && !(req.url ~ "&preview=true" ) <br>> ){<br>> unset req.http.cookie;<br>> }<br>><br>> # IF BASIC AUTH IS ON THEN DO NOT CACHE<br>> # ##############################<wbr>############################<br>> if (req.http.Authorization || req.http.Cookie) {<br>> return (pass);<br>> }<br>> <br>> # IF YOU GET HERE THEN THIS REQUEST SHOULD BE CACHED<br>> # ##############################<wbr>############################<br>> return (hash);<br>> # This is for phpmyadmin<br>> if (req.http.Host == "<a href="http://ki1.org" target="_blank">ki1.org</a>") {<br>> return (pass);<br>> }<br>><br>> if (req.http.Host == "<a href="http://mysql.ki1.org" target="_blank">mysql.ki1.org</a>") {<br>> return (pass);<br>> }<br>><br>> }<br>><br>> # HIT FUNCTION<br>> # ##############################<wbr>############################<br>> sub vcl_hit {<br>> # IF THIS IS A PURGE REQUEST THEN DO THE PURGE<br>> # ##############################<wbr>############################<br>> if (req.method == "PURGE") {<br>> #<br>> # This is now handled in vcl_recv.<br>> #<br>> # purge;<br>> return (synth(200, "Purged."));<br>> }<br>> return (deliver);<br>> }<br>><br>> # MISS FUNCTION<br>> # ##############################<wbr>############################<br>> sub vcl_miss {<br>> if (req.method == "PURGE") {<br>> #<br>> # This is now handled in vcl_recv.<br>> #<br>> # purge;<br>> return (synth(200, "Purged."));<br>> }<br>> return (fetch);<br>> }<br>><br>> # FETCH FUNCTION<br>> # ##############################<wbr>############################<br>> sub vcl_backend_response {<br>> # I SET THE VARY TO ACCEPT-ENCODING, THIS OVERRIDES W3TC <br>> # TENDANCY TO SET VARY USER-AGENT. YOU MAY OR MAY NOT WANT<br>> # TO DO THIS<br>> # ##############################<wbr>############################<br>> set beresp.http.Vary = "Accept-Encoding";<br>><br>> # IF NOT WP-ADMIN THEN UNSET COOKIES AND SET THE AMOUNT OF <br>> # TIME THIS PAGE WILL STAY CACHED (TTL)<br>> # ##############################<wbr>############################<br>> if (!(bereq.url ~ "wp-(login|admin)") && !bereq.http.cookie ~ "wordpress_logged_in" ) {<br>> unset beresp.http.set-cookie;<br>> set beresp.ttl = 52w;<br>> # set beresp.grace =1w;<br>> }<br>> <br>> if (beresp.http.Set-Cookie ~ "xf_(session|user)") {<br>> set beresp.uncacheable = true;<br>> set beresp.ttl = 1w;<br>> return (deliver);<br>> }<br>> <br>><br>> if (beresp.ttl <= 0s ||<br>> beresp.http.Set-Cookie ||<br>> beresp.http.Vary == "*") {<br>> set beresp.ttl = 120 s;<br>> # set beresp.ttl = 120s;<br>> set beresp.uncacheable = true;<br>> return (deliver);<br>> }<br>><br>> return (deliver);<br>> }<br>><br>> # DELIVER FUNCTION<br>> # ##############################<wbr>############################<br>> sub vcl_deliver {<br>> # IF THIS PAGE IS ALREADY CACHED THEN RETURN A 'HIT' TEXT <br>> # IN THE HEADER (GREAT FOR DEBUGGING)<br>> # ##############################<wbr>############################<br>> if (obj.hits > 0) {<br>> set resp.http.X-Cache = "HIT";<br>> # IF THIS IS A MISS RETURN THAT IN THE HEADER<br>> # ##############################<wbr>############################<br>> } else {<br>> set resp.http.X-Cache = "MISS";<br>> }<br>> }<br>><br>><br>><br>> 2016-08-04 16:36 GMT+03:00 Andrei <<a href="mailto:lagged@gmail.com" target="_blank">lagged@gmail.com</a>>:<br>>><br>>> correction:<br>>><br>>> sub vcl_recv {<br>>> if(req.http.Cookie ~ "xf_(session|user)") {<br>>> return (pass);<br>>> }<br>>> }<br>>><br>>> sub vcl_backend_response {<br>>> if (beresp.http.Set-Cookie ~ "xf_(session|user)") {<br>>> set beresp.uncacheable = true;<br>>> set beresp.ttl = 1w;<br>>> return (deliver);<br>>> }<br>>> }<br>>><br>>> On Thu, Aug 4, 2016 at 8:34 AM, Andrei <<a href="mailto:lagged@gmail.com" target="_blank">lagged@gmail.com</a>> wrote:<br>>>><br>>>> Hello,<br>>>><br>>>> Aside from the provided VCL being for WordPress, while you're running XenForo, the xf_ cookies are being dropped by your config. A quick fix is:<br>>>><br>>>> sub vcl_recv {<br>>>> if( req.http.Cookie ~ "xf_(session|user)") {<br>>>> return (pass);<br>>>> }<br>>>> }<br>>>><br>>>> sub vcl_backend_response {<br>>>> if (req.http.Cookie ~ "xf_(session|user)") {<br>>>> set beresp.uncacheable = true;<br>>>> set beresp.ttl = 1w;<br>>>> return (deliver);<br>>>> }<br>>>> }<br>>>><br>>>> However, I suggest auditing your VCL, and only including rules specific to the application(s) which you are running.<br>>>><br>>>><br>>>> On Thu, Aug 4, 2016 at 8:09 AM, Ayberk Kimsesiz <<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>> wrote:<br>>>>><br>>>>> Users can't login or register to <a href="http://domain.com/forum" target="_blank">domain.com/forum</a> with the current settings. So we need to make a change related to xf_user and xf_session but how?<br>>>>><br>>>>><br>>>>><br>>>>> 2016-08-04 15:26 GMT+03:00 Lane, Richard <<a href="mailto:rlane@ahbelo.com" target="_blank">rlane@ahbelo.com</a>>:<br>>>>>><br>>>>>> If you want Varnish to ignore request for a path you need to tell it to pass. In your example you have a rule for the RSS feed. You can do the same for /forum/ in your vcl_recv block.<br>>>>>><br>>>>>> *# DO NOT CACHE RSS FEED*<br>>>>>> * if (req.url ~ "/feed(/)?") {*<br>>>>>> * return ( pass ); *<br>>>>>> *}*<br>>>>>><br>>>>>> *# DO NOT CACHE FORUM*<br>>>>>> if (req.url ~ "/forum(/)?") {<br>>>>>> return ( pass ); <br>>>>>> }<br>>>>>><br>>>>>> Cheers,<br>>>>>> Richard<br>>>>>><br>>>>>>><br>>>>>>><br>>>>>>> Message: 1<br>>>>>>> Date: Wed, 3 Aug 2016 23:34:40 +0300<br>>>>>>> From: Ayberk Kimsesiz <<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>><br>>>>>>> To: varnish-misc <<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.or<wbr>g</a>><br>>>>>>> Subject: XenForo default.vcl settings<br>>>>>>> Message-ID:<br>>>>>>> <<a href="mailto:CAPQGzE29n1QOmHarn9L-9ztquGfeu-AwNJUaDrHm_w-5BXmA_Q@mail.gmail.com" target="_blank">CAPQGzE29n1QOmHarn9L-9ztquGfe<wbr>u-AwNJUaDrHm_w-5BXmA_Q@mail.<wbr>gmail.com</a>><br>>>>>>> Content-Type: text/plain; charset="utf-8"<br>>>>>>><br>>>>>>> Hi,<br>>>>>>><br>>>>>>> Could you please share the appropriate Default.vcl settings for XenForo<br>>>>>>> Forums? No one can register to the forum at the moment. My current<br>>>>>>> Default.vcl settings are as follows.<br>>>>>>><br>>>>>>> Forum address: <a href="http://domain.com/forum" target="_blank">domain.com/forum</a><br>>>>>>><br>>>>>>> */* SET THE HOST AND PORT OF WORDPRESS*<br>>>>>>> * * ******************************<wbr>***************************/*<br>>>>>>> *vcl 4.0;*<br>>>>>>> *import std;*<br>>>>>>><br>>>>>>> *backend default {*<br>>>>>>> * .host = "*******";*<br>>>>>>> * .port = "8080";*<br>>>>>>> * .connect_timeout = 600s;*<br>>>>>>> * .first_byte_timeout = 600s;*<br>>>>>>> * .between_bytes_timeout = 600s;*<br>>>>>>> * .max_connections = 800;*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# SET THE ALLOWED IP OF PURGE REQUESTS*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *acl purge {*<br>>>>>>> * "localhost";*<br>>>>>>> * "127.0.0.1";*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *#THE RECV FUNCTION*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *sub vcl_recv {*<br>>>>>>><br>>>>>>> *# set realIP by trimming CloudFlare IP which will be used for various<br>>>>>>> checks*<br>>>>>>> *set req.http.X-Actual-IP = regsub(req.http.X-Forwarded-Fo<wbr>r, "[, ].*$",<br>>>>>>> ""); *<br>>>>>>><br>>>>>>> * # FORWARD THE IP OF THE REQUEST*<br>>>>>>> * if (req.restarts == 0) {*<br>>>>>>> * if (req.http.x-forwarded-for) {*<br>>>>>>> * set req.http.X-Forwarded-For =*<br>>>>>>> * req.http.X-Forwarded-For + ", " + client.ip;*<br>>>>>>> * } else {*<br>>>>>>> * set req.http.X-Forwarded-For = client.ip;*<br>>>>>>> * }*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # Purge request check sections for hash_always_miss, purge and ban*<br>>>>>>> * # BLOCK IF NOT IP is not in purge acl*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>><br>>>>>>> * # Enable smart refreshing using hash_always_miss*<br>>>>>>> *if (req.http.Cache-Control ~ "no-cache") {*<br>>>>>>> * if (client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~<br>>>>>>> purge) {*<br>>>>>>> * set req.hash_always_miss = true;*<br>>>>>>> * }*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *if (req.method == "PURGE") {*<br>>>>>>> * if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~<br>>>>>>> purge) {*<br>>>>>>> * return(synth(405,"Not allowed."));*<br>>>>>>> * }*<br>>>>>>> * return (purge);*<br>>>>>>><br>>>>>>> * }*<br>>>>>>> *if (req.method == "BAN") {*<br>>>>>>> * # Same ACL check as above:*<br>>>>>>> * if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4")<br>>>>>>> ~ purge) {*<br>>>>>>> * return(synth(403, "Not allowed."));*<br>>>>>>> * }*<br>>>>>>> * ban("req.http.host == " + req.http.host +*<br>>>>>>> * " && req.url == " + req.url);*<br>>>>>>><br>>>>>>> * # Throw a synthetic page so the*<br>>>>>>> * # request won't go to the backend.*<br>>>>>>> * return(synth(200, "Ban added"));*<br>>>>>>> *}*<br>>>>>>><br>>>>>>><br>>>>>>> *# Unset cloudflare cookies*<br>>>>>>> *# Remove has_js and CloudFlare/Google Analytics __* cookies.*<br>>>>>>> * set req.http.Cookie = regsuball(req.http.Cookie,<br>>>>>>> "(^|;\s*)(_[_a-z]+|has_js)=[^;<wbr>]*", "");*<br>>>>>>> * # Remove a ";" prefix, if present.*<br>>>>>>> * set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");*<br>>>>>>><br>>>>>>> * # For Testing: If you want to test with Varnish passing (not caching)<br>>>>>>> uncomment*<br>>>>>>> * # return( pass );*<br>>>>>>><br>>>>>>> * # FORWARD THE IP OF THE REQUEST*<br>>>>>>> * if (req.restarts == 0) {*<br>>>>>>> * if (req.http.x-forwarded-for) {*<br>>>>>>> * set req.http.X-Forwarded-For =*<br>>>>>>> * req.http.X-Forwarded-For + ", " + client.ip;*<br>>>>>>> * } else {*<br>>>>>>> * set req.http.X-Forwarded-For = client.ip;*<br>>>>>>> * }*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> *# DO NOT CACHE RSS FEED*<br>>>>>>> * if (req.url ~ "/feed(/)?") {*<br>>>>>>> * return ( pass ); *<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *## Do not cache search results, comment these 3 lines if you do want to<br>>>>>>> cache them*<br>>>>>>><br>>>>>>> *if (req.url ~ "/\?s\=") {*<br>>>>>>> * return ( pass ); *<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# CLEAN UP THE ENCODING HEADER.*<br>>>>>>> * # SET TO GZIP, DEFLATE, OR REMOVE ENTIRELY. WITH VARY ACCEPT-ENCODING*<br>>>>>>> * # VARNISH WILL CREATE SEPARATE CACHES FOR EACH*<br>>>>>>> * # DO NOT ACCEPT-ENCODING IMAGES, ZIPPED FILES, AUDIO, ETC.*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (req.http.Accept-Encoding) {*<br>>>>>>> * if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz<wbr>|mp3|ogg)$") {*<br>>>>>>> * # No point in compressing these*<br>>>>>>> * unset req.http.Accept-Encoding;*<br>>>>>>> * } elsif (req.http.Accept-Encoding ~ "gzip") {*<br>>>>>>> * set req.http.Accept-Encoding = "gzip";*<br>>>>>>> * } elsif (req.http.Accept-Encoding ~ "deflate") {*<br>>>>>>> * set req.http.Accept-Encoding = "deflate";*<br>>>>>>> * } else {*<br>>>>>>> * # unknown algorithm*<br>>>>>>> * unset req.http.Accept-Encoding;*<br>>>>>>> * }*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # PIPE ALL NON-STANDARD REQUESTS*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (req.method != "GET" &&*<br>>>>>>> * req.method != "HEAD" &&*<br>>>>>>> * req.method != "PUT" && *<br>>>>>>> * req.method != "POST" &&*<br>>>>>>> * req.method != "TRACE" &&*<br>>>>>>> * req.method != "OPTIONS" &&*<br>>>>>>> * req.method != "DELETE") {*<br>>>>>>> * return (pipe);*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # ONLY CACHE GET AND HEAD REQUESTS*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (req.method != "GET" && req.method != "HEAD") {*<br>>>>>>> * return (pass);*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # OPTIONAL: DO NOT CACHE LOGGED IN USERS (THIS OCCURS IN FETCH TOO,<br>>>>>>> EITHER*<br>>>>>>> * # COMMENT OR UNCOMMENT BOTH*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if ( req.http.cookie ~ "wordpress_logged_in" ) {*<br>>>>>>> * return( pass );*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # IF THE REQUEST IS NOT FOR A PREVIEW, WP-ADMIN OR WP-LOGIN*<br>>>>>>> * # THEN UNSET THE COOKIES*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (!(req.url ~ "wp-(login|admin)") *<br>>>>>>> * && !(req.url ~ "&preview=true" ) *<br>>>>>>> * ){*<br>>>>>>> * unset req.http.cookie;*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # IF BASIC AUTH IS ON THEN DO NOT CACHE*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (req.http.Authorization || req.http.Cookie) {*<br>>>>>>> * return (pass);*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * # IF YOU GET HERE THEN THIS REQUEST SHOULD BE CACHED*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * return (hash);*<br>>>>>>> * # This is for phpmyadmin*<br>>>>>>> *if (req.http.Host == "<a href="http://ki1.org" target="_blank">ki1.org</a> <<a href="http://ki1.org" target="_blank">http://ki1.org</a>>") {*<br>>>>>>> *return (pass);*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *if (req.http.Host == "<a href="http://mysql.ki1.org" target="_blank">mysql.ki1.org</a> <<a href="http://mysql.ki1.org" target="_blank">http://mysql.ki1.org</a>>") {*<br>>>>>>> *return (pass);*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# HIT FUNCTION*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *sub vcl_hit {*<br>>>>>>> * # IF THIS IS A PURGE REQUEST THEN DO THE PURGE*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (req.method == "PURGE") {*<br>>>>>>> * #*<br>>>>>>> * # This is now handled in vcl_recv.*<br>>>>>>> * #*<br>>>>>>> * # purge;*<br>>>>>>> * return (synth(200, "Purged."));*<br>>>>>>> * }*<br>>>>>>> * return (deliver);*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# MISS FUNCTION*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *sub vcl_miss {*<br>>>>>>> * if (req.method == "PURGE") {*<br>>>>>>> * #*<br>>>>>>> * # This is now handled in vcl_recv.*<br>>>>>>> * #*<br>>>>>>> * # purge;*<br>>>>>>> * return (synth(200, "Purged."));*<br>>>>>>> * }*<br>>>>>>> * return (fetch);*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# FETCH FUNCTION*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *sub vcl_backend_response {*<br>>>>>>> * # I SET THE VARY TO ACCEPT-ENCODING, THIS OVERRIDES W3TC *<br>>>>>>> * # TENDANCY TO SET VARY USER-AGENT. YOU MAY OR MAY NOT WANT*<br>>>>>>> * # TO DO THIS*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * set beresp.http.Vary = "Accept-Encoding";*<br>>>>>>><br>>>>>>> * # IF NOT WP-ADMIN THEN UNSET COOKIES AND SET THE AMOUNT OF *<br>>>>>>> * # TIME THIS PAGE WILL STAY CACHED (TTL)*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (!(bereq.url ~ "wp-(login|admin)") && !bereq.http.cookie ~<br>>>>>>> "wordpress_logged_in" ) {*<br>>>>>>> * unset beresp.http.set-cookie;*<br>>>>>>> * set beresp.ttl = 52w;*<br>>>>>>> *# set beresp.grace =1w;*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * if (beresp.ttl <= 0s ||*<br>>>>>>> * beresp.http.Set-Cookie ||*<br>>>>>>> * beresp.http.Vary == "*") {*<br>>>>>>> * set beresp.ttl = 120 s;*<br>>>>>>> * # set beresp.ttl = 120s;*<br>>>>>>> * set beresp.uncacheable = true;*<br>>>>>>> * return (deliver);*<br>>>>>>> * }*<br>>>>>>><br>>>>>>> * return (deliver);*<br>>>>>>> *}*<br>>>>>>><br>>>>>>> *# DELIVER FUNCTION*<br>>>>>>> *# ##############################<wbr>############################*<br>>>>>>> *sub vcl_deliver {*<br>>>>>>> * # IF THIS PAGE IS ALREADY CACHED THEN RETURN A 'HIT' TEXT *<br>>>>>>> * # IN THE HEADER (GREAT FOR DEBUGGING)*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * if (obj.hits > 0) {*<br>>>>>>> * set resp.http.X-Cache = "HIT";*<br>>>>>>> * # IF THIS IS A MISS RETURN THAT IN THE HEADER*<br>>>>>>> * # ##############################<wbr>############################*<br>>>>>>> * } else {*<br>>>>>>> * set resp.http.X-Cache = "MISS";*<br>>>>>>> * }*<br>>>>>>> *}*<br>>>>>>><br>>>>>>><br>>>>>>> Thanks,<br>>>>>>> -------------- next part --------------<br>>>>>>> An HTML attachment was scrubbed...<br>>>>>>> URL: <<a href="https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160803/d572e4b2/attachment-0001.html" target="_blank">https://www.varnish-cache.org<wbr>/lists/pipermail/varnish-misc/<wbr>attachments/20160803/d572e4b2/<wbr>attachment-0001.html</a>><br>>>>>>><br>>>>>>> ------------------------------<br>>>>>>><br>>>>>>> Message: 2<br>>>>>>> Date: Thu, 4 Aug 2016 12:14:36 +0300<br>>>>>>> From: Ayberk Kimsesiz <<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>><br>>>>>>> To: varnish-misc <<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.or<wbr>g</a>><br>>>>>>> Subject: Re: XenForo default.vcl settings<br>>>>>>> Message-ID:<br>>>>>>> <<a href="mailto:CAPQGzE39XkXy_44z5oUXBO5q5sF5CvQmNP5k771DPi4O3i1ofA@mail.gmail.com" target="_blank">CAPQGzE39XkXy_44z5oUXBO5q5sF5<wbr>CvQmNP5k771DPi4O3i1ofA@mail.<wbr>gmail.com</a>><br>>>>>>> Content-Type: text/plain; charset="utf-8"<br>>>>>>><br>>>>>>> I need to add the followings to default.vcl for Xenforo. However, solutions<br>>>>>>> in the Xenforo forums for this didn't work. Can you please help?<br>>>>>>><br>>>>>>> xf_session_admin<br>>>>>>> xf_user<br>>>>>>> xf_session<br>>>>>>><br>>>>>>> Or how can i block Varnish in a way that it doesn't work in *<a href="http://domain.com/forum" target="_blank">domain.com/forum</a><br>>>>>>> <<a href="http://domain.com/forum" target="_blank">http://domain.com/forum</a>>*<br>>>>>>><br>>>>>>><br>>>>>>><br>>>>>>> 2016-08-03 23:34 GMT+03:00 Ayberk Kimsesiz <<a href="mailto:ayberk.kimsesiz@gmail.com" target="_blank">ayberk.kimsesiz@gmail.com</a>>:<br>>>>>>><br>>>>>>> > Hi,<br>>>>>>> ><br>>>>>>> > Could you please share the appropriate Default.vcl settings for XenForo<br>>>>>>> > Forums? No one can register to the forum at the moment. My current<br>>>>>>> > Default.vcl settings are as follows.<br>>>>>>> ><br>>>>>>> > Forum address: <a href="http://domain.com/forum" target="_blank">domain.com/forum</a><br>>>>>>> ><br>>>>>>> > */* SET THE HOST AND PORT OF WORDPRESS*<br>>>>>>> > * * ******************************<wbr>***************************/*<br>>>>>>> > *vcl 4.0;*<br>>>>>>> > *import std;*<br>>>>>>> ><br>>>>>>> > *backend default {*<br>>>>>>> > * .host = "*******";*<br>>>>>>> > * .port = "8080";*<br>>>>>>> > * .connect_timeout = 600s;*<br>>>>>>> > * .first_byte_timeout = 600s;*<br>>>>>>> > * .between_bytes_timeout = 600s;*<br>>>>>>> > * .max_connections = 800;*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# SET THE ALLOWED IP OF PURGE REQUESTS*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *acl purge {*<br>>>>>>> > * "localhost";*<br>>>>>>> > * "127.0.0.1";*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *#THE RECV FUNCTION*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *sub vcl_recv {*<br>>>>>>> ><br>>>>>>> > *# set realIP by trimming CloudFlare IP which will be used for various<br>>>>>>> > checks*<br>>>>>>> > *set req.http.X-Actual-IP = regsub(req.http.X-Forwarded-Fo<wbr>r, "[, ].*$",<br>>>>>>> > ""); *<br>>>>>>> ><br>>>>>>> > * # FORWARD THE IP OF THE REQUEST*<br>>>>>>> > * if (req.restarts == 0) {*<br>>>>>>> > * if (req.http.x-forwarded-for) {*<br>>>>>>> > * set req.http.X-Forwarded-For =*<br>>>>>>> > * req.http.X-Forwarded-For + ", " + client.ip;*<br>>>>>>> > * } else {*<br>>>>>>> > * set req.http.X-Forwarded-For = client.ip;*<br>>>>>>> > * }*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # Purge request check sections for hash_always_miss, purge and ban*<br>>>>>>> > * # BLOCK IF NOT IP is not in purge acl*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> ><br>>>>>>> > * # Enable smart refreshing using hash_always_miss*<br>>>>>>> > *if (req.http.Cache-Control ~ "no-cache") {*<br>>>>>>> > * if (client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~<br>>>>>>> > purge) {*<br>>>>>>> > * set req.hash_always_miss = true;*<br>>>>>>> > * }*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *if (req.method == "PURGE") {*<br>>>>>>> > * if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP, "1.2.3.4") ~<br>>>>>>> > purge) {*<br>>>>>>> > * return(synth(405,"Not allowed."));*<br>>>>>>> > * }*<br>>>>>>> > * return (purge);*<br>>>>>>> ><br>>>>>>> > * }*<br>>>>>>> > *if (req.method == "BAN") {*<br>>>>>>> > * # Same ACL check as above:*<br>>>>>>> > * if (!client.ip ~ purge || !std.ip(req.http.X-Actual-IP,<br>>>>>>> > "1.2.3.4") ~ purge) {*<br>>>>>>> > * return(synth(403, "Not allowed."));*<br>>>>>>> > * }*<br>>>>>>> > * ban("req.http.host == " + req.http.host +*<br>>>>>>> > * " && req.url == " + req.url);*<br>>>>>>> ><br>>>>>>> > * # Throw a synthetic page so the*<br>>>>>>> > * # request won't go to the backend.*<br>>>>>>> > * return(synth(200, "Ban added"));*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> ><br>>>>>>> > *# Unset cloudflare cookies*<br>>>>>>> > *# Remove has_js and CloudFlare/Google Analytics __* cookies.*<br>>>>>>> > * set req.http.Cookie = regsuball(req.http.Cookie,<br>>>>>>> > "(^|;\s*)(_[_a-z]+|has_js)=[^;<wbr>]*", "");*<br>>>>>>> > * # Remove a ";" prefix, if present.*<br>>>>>>> > * set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");*<br>>>>>>> ><br>>>>>>> > * # For Testing: If you want to test with Varnish passing (not caching)<br>>>>>>> > uncomment*<br>>>>>>> > * # return( pass );*<br>>>>>>> ><br>>>>>>> > * # FORWARD THE IP OF THE REQUEST*<br>>>>>>> > * if (req.restarts == 0) {*<br>>>>>>> > * if (req.http.x-forwarded-for) {*<br>>>>>>> > * set req.http.X-Forwarded-For =*<br>>>>>>> > * req.http.X-Forwarded-For + ", " + client.ip;*<br>>>>>>> > * } else {*<br>>>>>>> > * set req.http.X-Forwarded-For = client.ip;*<br>>>>>>> > * }*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > *# DO NOT CACHE RSS FEED*<br>>>>>>> > * if (req.url ~ "/feed(/)?") {*<br>>>>>>> > * return ( pass ); *<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *## Do not cache search results, comment these 3 lines if you do want to<br>>>>>>> > cache them*<br>>>>>>> ><br>>>>>>> > *if (req.url ~ "/\?s\=") {*<br>>>>>>> > * return ( pass ); *<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# CLEAN UP THE ENCODING HEADER.*<br>>>>>>> > * # SET TO GZIP, DEFLATE, OR REMOVE ENTIRELY. WITH VARY ACCEPT-ENCODING*<br>>>>>>> > * # VARNISH WILL CREATE SEPARATE CACHES FOR EACH*<br>>>>>>> > * # DO NOT ACCEPT-ENCODING IMAGES, ZIPPED FILES, AUDIO, ETC.*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (req.http.Accept-Encoding) {*<br>>>>>>> > * if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz<wbr>|mp3|ogg)$") {*<br>>>>>>> > * # No point in compressing these*<br>>>>>>> > * unset req.http.Accept-Encoding;*<br>>>>>>> > * } elsif (req.http.Accept-Encoding ~ "gzip") {*<br>>>>>>> > * set req.http.Accept-Encoding = "gzip";*<br>>>>>>> > * } elsif (req.http.Accept-Encoding ~ "deflate") {*<br>>>>>>> > * set req.http.Accept-Encoding = "deflate";*<br>>>>>>> > * } else {*<br>>>>>>> > * # unknown algorithm*<br>>>>>>> > * unset req.http.Accept-Encoding;*<br>>>>>>> > * }*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # PIPE ALL NON-STANDARD REQUESTS*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (req.method != "GET" &&*<br>>>>>>> > * req.method != "HEAD" &&*<br>>>>>>> > * req.method != "PUT" && *<br>>>>>>> > * req.method != "POST" &&*<br>>>>>>> > * req.method != "TRACE" &&*<br>>>>>>> > * req.method != "OPTIONS" &&*<br>>>>>>> > * req.method != "DELETE") {*<br>>>>>>> > * return (pipe);*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # ONLY CACHE GET AND HEAD REQUESTS*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (req.method != "GET" && req.method != "HEAD") {*<br>>>>>>> > * return (pass);*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # OPTIONAL: DO NOT CACHE LOGGED IN USERS (THIS OCCURS IN FETCH TOO,<br>>>>>>> > EITHER*<br>>>>>>> > * # COMMENT OR UNCOMMENT BOTH*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if ( req.http.cookie ~ "wordpress_logged_in" ) {*<br>>>>>>> > * return( pass );*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # IF THE REQUEST IS NOT FOR A PREVIEW, WP-ADMIN OR WP-LOGIN*<br>>>>>>> > * # THEN UNSET THE COOKIES*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (!(req.url ~ "wp-(login|admin)") *<br>>>>>>> > * && !(req.url ~ "&preview=true" ) *<br>>>>>>> > * ){*<br>>>>>>> > * unset req.http.cookie;*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # IF BASIC AUTH IS ON THEN DO NOT CACHE*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (req.http.Authorization || req.http.Cookie) {*<br>>>>>>> > * return (pass);*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * # IF YOU GET HERE THEN THIS REQUEST SHOULD BE CACHED*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * return (hash);*<br>>>>>>> > * # This is for phpmyadmin*<br>>>>>>> > *if (req.http.Host == "<a href="http://ki1.org" target="_blank">ki1.org</a> <<a href="http://ki1.org" target="_blank">http://ki1.org</a>>") {*<br>>>>>>> > *return (pass);*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *if (req.http.Host == "<a href="http://mysql.ki1.org" target="_blank">mysql.ki1.org</a> <<a href="http://mysql.ki1.org" target="_blank">http://mysql.ki1.org</a>>") {*<br>>>>>>> > *return (pass);*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# HIT FUNCTION*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *sub vcl_hit {*<br>>>>>>> > * # IF THIS IS A PURGE REQUEST THEN DO THE PURGE*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (req.method == "PURGE") {*<br>>>>>>> > * #*<br>>>>>>> > * # This is now handled in vcl_recv.*<br>>>>>>> > * #*<br>>>>>>> > * # purge;*<br>>>>>>> > * return (synth(200, "Purged."));*<br>>>>>>> > * }*<br>>>>>>> > * return (deliver);*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# MISS FUNCTION*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *sub vcl_miss {*<br>>>>>>> > * if (req.method == "PURGE") {*<br>>>>>>> > * #*<br>>>>>>> > * # This is now handled in vcl_recv.*<br>>>>>>> > * #*<br>>>>>>> > * # purge;*<br>>>>>>> > * return (synth(200, "Purged."));*<br>>>>>>> > * }*<br>>>>>>> > * return (fetch);*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# FETCH FUNCTION*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *sub vcl_backend_response {*<br>>>>>>> > * # I SET THE VARY TO ACCEPT-ENCODING, THIS OVERRIDES W3TC *<br>>>>>>> > * # TENDANCY TO SET VARY USER-AGENT. YOU MAY OR MAY NOT WANT*<br>>>>>>> > * # TO DO THIS*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * set beresp.http.Vary = "Accept-Encoding";*<br>>>>>>> ><br>>>>>>> > * # IF NOT WP-ADMIN THEN UNSET COOKIES AND SET THE AMOUNT OF *<br>>>>>>> > * # TIME THIS PAGE WILL STAY CACHED (TTL)*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (!(bereq.url ~ "wp-(login|admin)") && !bereq.http.cookie ~<br>>>>>>> > "wordpress_logged_in" ) {*<br>>>>>>> > * unset beresp.http.set-cookie;*<br>>>>>>> > * set beresp.ttl = 52w;*<br>>>>>>> > *# set beresp.grace =1w;*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * if (beresp.ttl <= 0s ||*<br>>>>>>> > * beresp.http.Set-Cookie ||*<br>>>>>>> > * beresp.http.Vary == "*") {*<br>>>>>>> > * set beresp.ttl = 120 s;*<br>>>>>>> > * # set beresp.ttl = 120s;*<br>>>>>>> > * set beresp.uncacheable = true;*<br>>>>>>> > * return (deliver);*<br>>>>>>> > * }*<br>>>>>>> ><br>>>>>>> > * return (deliver);*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> > *# DELIVER FUNCTION*<br>>>>>>> > *# ##############################<wbr>############################*<br>>>>>>> > *sub vcl_deliver {*<br>>>>>>> > * # IF THIS PAGE IS ALREADY CACHED THEN RETURN A 'HIT' TEXT *<br>>>>>>> > * # IN THE HEADER (GREAT FOR DEBUGGING)*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * if (obj.hits > 0) {*<br>>>>>>> > * set resp.http.X-Cache = "HIT";*<br>>>>>>> > * # IF THIS IS A MISS RETURN THAT IN THE HEADER*<br>>>>>>> > * # ##############################<wbr>############################*<br>>>>>>> > * } else {*<br>>>>>>> > * set resp.http.X-Cache = "MISS";*<br>>>>>>> > * }*<br>>>>>>> > *}*<br>>>>>>> ><br>>>>>>> ><br>>>>>>> > Thanks,<br>>>>>>> ><br>>>>>>> -------------- next part --------------<br>>>>>>> An HTML attachment was scrubbed...<br>>>>>>> URL: <<a href="https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160804/4e3f064a/attachment.html" target="_blank">https://www.varnish-cache.org<wbr>/lists/pipermail/varnish-misc/<wbr>attachments/20160804/4e3f064a/<wbr>attachment.html</a>><br>>>>>>><br>>>>>>> ------------------------------<br>>>>>>><br>>>>>>> ______________________________<wbr>_________________<br>>>>>>> varnish-misc mailing list<br>>>>>>> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>>>>>>> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/varnish<wbr>-misc</a><br>>>>>>><br>>>>>>> End of varnish-misc Digest, Vol 125, Issue 14<br>>>>>>> ******************************<wbr>***************<br>>>>>><br>>>>>><br>>>>>><br>>>>>> ______________________________<wbr>_________________<br>>>>>> varnish-misc mailing list<br>>>>>> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>>>>>> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/varnish<wbr>-misc</a><br>>>>><br>>>>><br>>>>><br>>>>> ______________________________<wbr>_________________<br>>>>> varnish-misc mailing list<br>>>>> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>>>>> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/varnish<wbr>-misc</a><br>>>><br>>>><br>>><br>><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>