Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to apply the VCL to 192.168.137.132:80: Varnish admin socket timeout" #9

Closed
mosesdinakaran opened this issue Nov 28, 2012 · 4 comments

Comments

@mosesdinakaran
Copy link

Hi,

After installing the extension I am getting below error.
"Failed to apply the VCL to 192.168.137.132:80: Varnish admin socket timeout"

Could you please tell me what could be the reason for this error.

The varnish config file is created properly.

Details of my environment:
Varnish and apache are in the same server.

Server Ip : 192.168.137.132
Varnish Port : 80
Apache Port : 8080

Extension Settings

Varnish Options
Varnish Version : 3.0x
Server List : 192.168.137.132:80

Caching Options
Backend Host : 192.168.137.132
Backend Port : 8080
Crawler IP Addresses : 192.168.137.132

Regards,

Moses

VCL File:

import std;
backend default {
.host = "192.168.137.132";
.port = "8080";
.first_byte_timeout = 300s;
.between_bytes_timeout = 300s;
}
backend admin {
.host = "192.168.137.132";
.port = "8080";
.first_byte_timeout = 21600s;
.between_bytes_timeout = 21600s;
}
acl crawler_acl {
"127.0.0.1";
}
sub remove_cache_headers {
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
unset beresp.http.Pragma;
unset beresp.http.Cache;
unset beresp.http.Age;
}
sub remove_double_slashes {
set req.url = regsub(req.url, "(.)//+(.)", "\1/\2");
}
sub vcl_recv {
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "DELETE" &&
req.request != "OPTIONS") {
/* Non-RFC2616 or CONNECT which is weird. /
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
/
We only deal with GET and HEAD by default /
return (pipe);
}
call remove_double_slashes;
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} else if (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
if (!true || req.http.Authorization) {
return (pipe);
}
if (req.url ~ "^/(?:(?:index|litespeed).php/)?admin") {
set req.backend = admin;
return (pipe);
}
if (req.url ~ "^/(?:(?:index|litespeed).php/)?turpentine/esi/getBlock" &&
req.esi_level == 0) {
error 403 "External ESI requests are not allowed";
}
if (req.url ~ "^/(?:(?:index|litespeed).php/)?") {
if (req.http.Cookie ~ "frontend=") {
set req.http.X-Varnish-Cookie = req.http.Cookie;
} else {
if (client.ip ~ crawler_acl ) {
set req.http.Cookie = "frontend=no-session";
set req.http.X-Varnish-Cookie = req.http.Cookie;
} else {
return (pass);
}
}
if (true &&
req.url ~ ".
.(?:css|js|jpe?g|png|gif|ico|swf)(?=?|$)") {
unset req.http.Cookie;
return (lookup);
}
if (req.url ~ "^/(?:(?:index|litespeed).php/)?(?:admin|api|cron.php)") {
return (pass);
}
if (true &&
req.url ~ "(?:?&(?=[&=]|$))") {
return (pass);
}
return (lookup);
}
}
sub vcl_pipe {
set req.http.Connection = "close";
return (pipe);
}
sub vcl_pass {
if (req.esi_level == 0 && req.http.X-Varnish-Cookie) {
unset req.http.Cookie;
} elsif (req.esi_level > 0 && req.http.X-Varnish-Cookie) {
set req.http.Cookie = req.http.X-Varnish-Cookie;
}
return (pass);
}
sub vcl_hash {
hash_data(req.url);
if (req.http.Host) {
hash_data(req.http.Host);
} else {
hash_data(server.ip);
}
if (req.http.X-Normalized-User-Agent) {
hash_data(req.http.X-Normalized-User-Agent);
}
if (req.http.Accept-Encoding) {
hash_data(req.http.Accept-Encoding);
}
if (req.url ~ "^/(?:(?:index|litespeed).php/)?turpentine/esi/getBlock/.") {
if (req.url ~ "/cacheType/per-client/" && req.http.Cookie ~ "frontend=") {
hash_data(regsub(req.http.Cookie, "^.
?frontend=([^;]);.$", "\1"));
}
}
return (hash);
}
sub vcl_miss {
if (req.esi_level == 0 && req.http.X-Varnish-Cookie) {
unset req.http.Cookie;
} elsif (req.esi_level > 0 && req.http.X-Varnish-Cookie) {
set req.http.Cookie = req.http.X-Varnish-Cookie;
}
return (fetch);
}
sub vcl_fetch {
set req.grace = 15s;
unset beresp.http.Vary;
if (beresp.status != 200 && beresp.status != 404) {
set beresp.ttl = 15s;
return (hit_for_pass);
} else {
if (beresp.http.Set-Cookie) {
set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;
unset beresp.http.Set-Cookie;
}
if (req.esi_level == 0 &&
req.http.X-Varnish-Cookie !~ "frontend=" &&
client.ip !~ crawler_acl) {
set beresp.http.X-Varnish-Use-Set-Cookie = "1";
}
if (beresp.http.X-Turpentine-Esi ~ "1") {
set beresp.do_esi = true;
}
set beresp.do_gzip = true;
if (beresp.http.X-Turpentine-Cache ~ "0") {
set beresp.ttl = 15s;
return (hit_for_pass);
} else {
unset beresp.http.Vary;
if (true &&
bereq.url ~ ".
.(?:css|js|jpe?g|png|gif|ico|swf)(?=?|$)") {
call remove_cache_headers;
set beresp.ttl = 28800s;
} elseif (req.url ~ "^/(?:(?:index|litespeed).php/)?turpentine/esi/getBlock/.") {
call remove_cache_headers;
if (req.url ~ "/cacheType/per-client/" &&
req.http.Cookie ~ "frontend=") {
set beresp.http.X-Varnish-Session = regsub(req.http.Cookie,
"^.
?frontend=([^;]);.$", "\1");
}
set beresp.ttl = std.duration(regsub(req.url,
".
/ttl/([0-9]+)/.*", "\1s"), 300s);
} else {
call remove_cache_headers;
set beresp.ttl = 3600s;
}
}
}
return (deliver);
}
sub vcl_deliver {
if (resp.http.X-Varnish-Use-Set-Cookie) {
set resp.http.Set-Cookie = resp.http.X-Varnish-Set-Cookie;
}
if (true) {
set resp.http.X-Varnish-Hits = obj.hits;
} else {
unset resp.http.X-Varnish;
unset resp.http.Via;
unset resp.http.X-Powered-By;
unset resp.http.Server;
unset resp.http.Age;
unset resp.http.X-Turpentine-Cache;
unset resp.http.X-Turpentine-Esi;
unset resp.http.X-Varnish-Session;
unset resp.http.X-Varnish-Set-Cookie;
unset resp.http.X-Varnish-Use-Set-Cookie;
}
}


/etc/sysconfig/varnish content:

NFILES=131072
MEMLOCK=82000
RELOAD_VCL=1

VARNISH_VCL_CONF=/etc/varnish/magento.vcl

VARNISH_VCL_CONF=/var/www/megaoffersaledev.in/var/default.vcl
VARNISH_LISTEN_PORT=80
VARNISH_ADMIN_LISTEN_PORT=8888
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_MIN_THREADS=1
VARNISH_MAX_THREADS=1000
VARNISH_THREAD_TIMEOUT=120
VARNISH_CACHE_SIZE=12G
VARNISH_CACHE="malloc,${VARNISH_CACHE_SIZE}"
VARNISH_TTL=120
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT}
-f ${VARNISH_VCL_CONF}
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT}
-t ${VARNISH_TTL}
-w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT}
-u varnish -g varnish
-S ${VARNISH_SECRET_FILE} \

-s ${VARNISH_CACHE}"

@aheadley
Copy link
Contributor

The Server List option should contain the management interfaces for Varnish (where Varnish listens for admin commands), which is not the same as the listen interfaces (where Varnish listens for external requests). Based on the config you sent, try changing the Server List option to:

192.168.137.132:8888

@mosesdinakaran
Copy link
Author

Hi,
Thanks for the reply It worked, I have successfully installed and configured. Site is loading very fast :)
But unfortunately ESI is not working was testing that.

If any one faces the below issue

Failed to apply the VCL to 192.168.137.132:8888: Sent command: "auth" "b2f849c9120b9b1ded3e90814d55dddb97614b77aac527bb0f464386aaef3843" Got unexpected response code from Varnish: 107 qqqdpnxkljalertwipnmrgrcypbxdzdv Authentication required.

Try adding "\n" at the end of the secret key (Varnish Authentication Key)

It worked for me.

Thanks for the Extension,
Moses.

@egurbich
Copy link

Try adding "\n" at the end of the secret key (Varnish Authentication Key) - IT WORKS! THANKS A LOT! :)

@franckcharpentier
Copy link

Try adding "\n" at the end of the secret key (Varnish Authentication Key)

Thanks a lot. It also works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants