[Varnish] #1633: Change backend director doesn't work
Varnish
varnish-bugs at varnish-cache.org
Wed Nov 26 09:16:03 CET 2014
#1633: Change backend director doesn't work
------------------------------+--------------------
Reporter: steven.raccourci | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version: 4.0.2
Severity: normal | Resolution:
Keywords: director |
------------------------------+--------------------
Comment (by steven.raccourci):
Sorry for the late response.
So here is the full vcl_recv :
{{{
# Handle the HTTP request received by the client
sub vcl_recv {
# Choose the round-robin backend
set req.backend_hint = cluster_public.backend();
# shortcut for DFind requests
if (req.url ~ "^/w00tw00t") {
return (synth(404, "Not Found"));
}
if (req.restarts == 0) {
if (!req.http.X-Real-IP) {
set req.http.X-Real-IP = client.ip;
}
}
# Normalize the header, remove the port (in case you're testing this
on various TCP ports)
set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");
# Allow purging
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
# Not from an allowed IP? Then die with an error.
return (synth(405, "This IP is not allowed to send PURGE
requests."));
}
# If you got this stage (and didn't error out above), purge the
cached result
return (purge);
}
# Allow ban
if (req.method == "BAN") {
if (!client.ip ~ purge) {
# Not from an allowed IP? Then die with an error.
return (synth(405, "This IP is not allowed to send PURGE
requests."));
}
if (req.url != "/") {
# Ban every cache object containing the given tag
ban("obj.http.x-domain == " + req.http.host + " && obj.http.x
-drupal-cache-tags ~ " + regsuball(req.url, "^/", ""));
} else {
# Ban the full domain
ban("obj.http.x-domain == " + req.http.host);
}
return(synth(200, "BAN added"));
}
# Only deal with "normal" types
if (req.method != "GET" &&
req.method != "HEAD" &&
req.method != "PUT" &&
req.method != "POST" &&
req.method != "TRACE" &&
req.method != "OPTIONS" &&
req.method != "PATCH" &&
req.method != "DELETE") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
# Only cache GET or HEAD requests. This makes sure the POST requests
are always passed.
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
}
# Don't cache. This makes sure requests are to this URL always passed.
if (req.http.Cache-Control ~ "no-cache" ||
req.url ~ "^/phpmyadmin" ||
req.url ~ "^/user" ||
req.url ~ "^/apc") {
return (pass);
}
# Some generic URL manipulation, useful for all templates that follow
# First remove the Google Analytics added parameters, useless for our
backend
if (req.url ~
"(\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url,
"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)",
"");
set req.url = regsuball(req.url,
"\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)",
"?");
set req.url = regsub(req.url, "\?&", "?");
set req.url = regsub(req.url, "\?$", "");
}
# Strip a trailing ? if it exists
if (req.url ~ "\?$") {
set req.url = regsub(req.url, "\?$", "");
}
# Normalize Accept-Encoding header
# straight from the manual: https://www.varnish-
cache.org/docs/3.0/tutorial/vary.html
if (req.http.Accept-Encoding) {
if (req.url ~
"\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|tgz|rar|zip|mp[34]|ogg|wav)$") {
# No point in compressing these
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
# unkown algorithm
unset req.http.Accept-Encoding;
}
}
# Large static files should be piped, so they are delivered directly
to the end-user without
# waiting for Varnish to fully read the file first.
if (req.url ~
"^[^?]*\.(gz|bz2|tbz|zip|tgz|rar|doc|docx|xls|xlsx|odt|flv|pdf|rtf|swf|mp[34]|ogg|wav|bmp|gif|ico|jpeg|jpg|png|css|js|less|eot|ttf|woff|txt|xml|html|htm)(\?.*)?$")
{
unset req.http.Cookie;
return (pass);
}
# Remove all cookies
if (req.http.Cookie) {
# Forward to the backend admin if a session exists and disable
cache
if (req.http.Cookie ~ "SESS[a-z0-9]+") {
set req.backend_hint = cluster_admin.backend();
return (pass);
}
# Remove all cookies for SSO My Account
if (req.url ~ "^/api/myaccount" && req.http.Cookie ~ "RC-API-
SESSID") {
return (pass);
}
unset req.http.Cookie;
}
return (hash);
}
}}}
Here is the results of varnishlog ({{{varnishlog -g request -w varnish.log
-q "ReqURL eq '/?foo'"}}}), (drupalf2 is the name of one of our public
backends) :
{{{
* << Request >> 390792402
- Begin req 390792401 rxreq
- Timestamp Start: 1416989650.113073 0.000000 0.000000
- Timestamp Req: 1416989650.113073 0.000000 0.000000
- ReqStart 10.7.0.18 50119
- ReqMethod GET
- ReqURL /?foo
- ReqProtocol HTTP/1.1
- ReqHeader Host: www.saintlary.com
- ReqHeader Connection: keep-alive
- ReqHeader Pragma: no-cache
- ReqHeader Cache-Control: no-cache
- ReqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
- ReqHeader User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
- ReqHeader Accept-Encoding: gzip,deflate,sdch
- ReqHeader Accept-Language: fr,en-US;q=0.8,en;q=0.6,fr-FR;q=0.4
- ReqHeader Cookie: ot-st-lary_hiver=0eede76i7r27oplrvrgje3n4r7;
ot-st-lary_ete=1481bou3q47hpcadt0vf3q36m2;
__utma=1.1558254274.1414403769.1414403769.1414403769.1;
__utmz=1.1414403769.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided);
SESS243
- ReqHeader X-Forwarded-For: 10.7.0.18
- VCL_call RECV
- ReqHeader X-Real-IP: 10.7.0.18
- ReqUnset Host: www.saintlary.com
- ReqHeader Host: www.saintlary.com
- VCL_return pass
- VCL_call HASH
- VCL_return lookup
- VCL_call PASS
- VCL_return fetch
- Link bereq 390792403 pass
- Timestamp Fetch: 1416989650.326714 0.213640 0.213640
- RespProtocol HTTP/1.1
- RespStatus 200
- RespReason OK
- RespHeader Date: Wed, 26 Nov 2014 08:14:10 GMT
- RespHeader Server: Apache
- RespHeader Expires: Sun, 19 Nov 1978 05:00:00 GMT
- RespHeader Last-Modified: Wed, 26 Nov 2014 08:14:10 +0000
- RespHeader Cache-Control: no-cache, must-revalidate, post-check=0,
pre-check=0
- RespHeader ETag: "1416989650"
- RespHeader Content-Language: fr
- RespHeader Vary: Accept-Encoding
- RespHeader Content-Encoding: gzip
- RespHeader Content-Type: text/html; charset=utf-8
- RespHeader X-Backend: drupalf2
- RespHeader X-Domain: www.saintlary.com
- RespHeader X-Varnish: 390792402
- RespHeader Age: 0
- RespHeader Via: 1.1 varnish-v4
- VCL_call DELIVER
- RespHeader X-Varnish-Cache: MISS
- RespUnset Server: Apache
- RespUnset X-Domain: www.saintlary.com
- RespUnset X-Varnish: 390792402
- RespUnset Via: 1.1 varnish-v4
- VCL_return deliver
- Timestamp Process: 1416989650.326740 0.213666 0.000026
- Debug "RES_MODE 8"
- RespHeader Transfer-Encoding: chunked
- RespHeader Connection: keep-alive
- RespHeader Accept-Ranges: bytes
- Timestamp Resp: 1416989650.327441 0.214367 0.000701
- Debug "XXX REF 1"
- ReqAcct 988 0 988 468 20602 21070
- End
** << BeReq >> 390792403
-- Begin bereq 390792402 pass
-- Timestamp Start: 1416989650.113177 0.000000 0.000000
-- BereqMethod GET
-- BereqURL /?foo
-- BereqProtocol HTTP/1.1
-- BereqHeader Pragma: no-cache
-- BereqHeader Cache-Control: no-cache
-- BereqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
-- BereqHeader User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
-- BereqHeader Accept-Encoding: gzip,deflate,sdch
-- BereqHeader Accept-Language: fr,en-US;q=0.8,en;q=0.6,fr-FR;q=0.4
-- BereqHeader Cookie: ot-st-lary_hiver=0eede76i7r27oplrvrgje3n4r7;
ot-st-lary_ete=1481bou3q47hpcadt0vf3q36m2;
__utma=1.1558254274.1414403769.1414403769.1414403769.1;
__utmz=1.1414403769.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided);
SESS243
-- BereqHeader X-Forwarded-For: 10.7.0.18
-- BereqHeader X-Real-IP: 10.7.0.18
-- BereqHeader Host: www.saintlary.com
-- BereqHeader X-Varnish: 390792403
-- VCL_call BACKEND_FETCH
-- VCL_return fetch
-- BackendOpen 13 drupalf2(10.14.0.41,,80) 10.14.0.38 60648
-- Backend 13 cluster_public drupalf2(10.14.0.41,,80)
-- Timestamp Bereq: 1416989650.113477 0.000300 0.000300
-- Timestamp Beresp: 1416989650.326505 0.213328 0.213028
-- BerespProtocol HTTP/1.1
-- BerespStatus 200
-- BerespReason OK
-- BerespHeader Date: Wed, 26 Nov 2014 08:14:10 GMT
-- BerespHeader Server: Apache
-- BerespHeader Expires: Sun, 19 Nov 1978 05:00:00 GMT
-- BerespHeader Last-Modified: Wed, 26 Nov 2014 08:14:10 +0000
-- BerespHeader Cache-Control: no-cache, must-revalidate, post-check=0,
pre-check=0
-- BerespHeader ETag: "1416989650"
-- BerespHeader Content-Language: fr
-- BerespHeader Vary: Accept-Encoding
-- BerespHeader Content-Encoding: gzip
-- BerespHeader Connection: close
-- BerespHeader Transfer-Encoding: chunked
-- BerespHeader Content-Type: text/html; charset=utf-8
-- TTL RFC 0 -1 -1 1416989650 1416989650 1416989650 280299600
0
-- VCL_call BACKEND_RESPONSE
-- BerespHeader X-Backend: drupalf2
-- BerespHeader X-Domain: www.saintlary.com
-- TTL VCL 0 10 0 1416989650
-- VCL_return deliver
-- Storage malloc Transient
-- ObjProtocol HTTP/1.1
-- ObjStatus 200
-- ObjReason OK
-- ObjHeader Date: Wed, 26 Nov 2014 08:14:10 GMT
-- ObjHeader Server: Apache
-- ObjHeader Expires: Sun, 19 Nov 1978 05:00:00 GMT
-- ObjHeader Last-Modified: Wed, 26 Nov 2014 08:14:10 +0000
-- ObjHeader Cache-Control: no-cache, must-revalidate, post-check=0,
pre-check=0
-- ObjHeader ETag: "1416989650"
-- ObjHeader Content-Language: fr
-- ObjHeader Vary: Accept-Encoding
-- ObjHeader Content-Encoding: gzip
-- ObjHeader Content-Type: text/html; charset=utf-8
-- ObjHeader X-Backend: drupalf2
-- ObjHeader X-Domain: www.saintlary.com
-- Fetch_Body 2 chunked stream
-- Gzip u F - 20587 144037 80 164616 164626
-- Timestamp BerespBody: 1416989650.327351 0.214174 0.000846
-- BackendClose 13 drupalf2(10.14.0.41,,80)
-- Length 20587
-- BereqAcct 1036 0 1036 405 20604 21009
-- End
}}}
Our session ids are md5 alike with no uppercase character.
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1633#comment:4>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list