varnish – Hitch installation completed with insserv errors. Unable to start hitch

I am trying to install hitch to terminate the certificates for the Varnish reverse proxy on my Ubuntu 16.04 VPS. The installation completes with the following messages and Hitch service doesnt startup.

sridhar@SastraTechnologies:~$ sudo apt install hitch
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 100 not upgraded.
Need to get 0 B/51.1 kB of archives.
After this operation, 163 kB of additional disk space will be used.
Selecting previously unselected package hitch.
(Reading database ... 249839 files and directories currently installed.)
Preparing to unpack .../hitch_1.1.1-1_amd64.deb ...
Unpacking hitch (1.1.1-1) ...
Processing triggers for systemd (229-4ubuntu21.27) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up hitch (1.1.1-1) ...
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:'  entry: please add even if empty.
insserv: missing `Default-Stop:'   entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nagios'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `nagios'

Tried removing the packahe updating the repository and installing it again but the results are the same. Is there anything that I can do to resolve the insserv messages?

caching – Getting Miss always in varnish cache for the page using REST API

While hitting URL using REST API, it is always giving Miss for varnish cache for specific path and giving response from Memcahce. In header if we can check for cache-control we are getting “must-revalidate, no-cache, private”. Can someone guide us what exactly the issue or help us with the solution.

magento2.4 – Magento 2.4 Varnish error STACK OVERFLOW

I have a dockerised M2.4 installation. All worked fine with my theme and the installed extensions while working with Magento demo data. As soon as update the database with the live data I cannot get Varnish to work correctly. Contact page loads and non cached pages, but only the header will load for all other pages. Having checked the varnish container logs I see the following error below. It appears to be asking for more resources so I have updated /etc/default/varnish as follows:

DAEMON_OPTS=”-a :6081
-T localhost:6082
-f /etc/varnish/default.vcl
-S /etc/varnish/secret
-p thread_pool_stack=4096k
-p http_resp_hdr_len=65536
-p http_resp_size=98304
-p thread_pool_min=50
-p thread_pool_max=1000
-s malloc,256m”

Doesn’t seem to matter how high I set thread_pool_stack it still makes no difference. Any pointers or ideas much appreciated.

Debug: Child (8159) Started
Info: Child (8159) said Child starts
Error: Child (8159) died signal=6 (core dumped)
Error: Child (8159) Panic at: Thu, 22 Oct 2020 15:51:27 GMT
Wrong turn at cache/cache_main.c:284:
Signal 11 (Segmentation fault) received at 0x7f5bc4c56ff8 si_code 2
THIS PROBABLY IS A STACK OVERFLOW – check thread_pool_stack parameter
version = varnish-6.1.1 revision efc2f6c1536cf2272e471f5cff5f145239b19460, vrt api = 8.0
ident = Linux,5.4.0-26-generic,x86_64,-junix,-smalloc,-sdefault,-hcritbit,epoll
now = 691226.238573 (mono), 1603381887.549008 (real)
0x55809884dd2a: varnishd(+0x4cd2a) (0x55809884dd2a)
0x5580988b5cc3: varnishd(VAS_Fail+0x13) (0x5580988b5cc3)
0x558098849736: varnishd(+0x48736) (0x558098849736)
0x7f5bd1505730: /lib/x86_64-linux-gnu/ (0x7f5bd1505730)
0x7f5bd16ea6d0: /lib/x86_64-linux-gnu/ (0x7f5bd16ea6d0)
0x7f5bd17117d8: /lib/x86_64-linux-gnu/ (0x7f5bd17117d8)
0x7f5bd16e84da: /lib/x86_64-linux-gnu/ (0x7f5bd16e84da)
0x5580988bceb0: varnishd(VRE_exec+0x80) (0x5580988bceb0)
0x558098866ac0: varnishd(VRT_regsub+0xd0) (0x558098866ac0)
0x7f5bc4d1cd91: vcl_boot.1603381053.170923471/ (0x7f5bc4d1cd91)
thread = (cache-worker)
thr.req = 0x7f5bc00aac20 {
vxid = 32772, transport = ESI_INCLUDE
step = R_STP_RECV,
req_body = R_BODY_NONE,
restarts = 0, esi_level = 1,
sp = 0x7f5bbfc01220 {
fd = 22, vxid = 32769,
t_open = 1603381885.250061,
t_idle = 1603381885.250061,
ws = 0x7f5bbfc01260 {
id = “ses”,
{s, f, r, e} = {0x7f5bbfc01298, +96, (nil), +352},
transport = HTTP/1 {
state = HTTP1::Proc
client = 55530 :80,
worker = 0x7f5bc4c605c0 {
ws = 0x7f5bc4c60668 {
id = “wrk”,
{s, f, r, e} = {0x7f5bc4c5f950, +264, (nil), +2040},
VCL::method = inside RECV,
VCL::return = 0x0,
ws = 0x7f5bc00aad70 {
id = “req”,
{s, f, r, e} = {0x7f5bc00acca8, +80, (nil), +57168},
http_conn = 0x7f5bc00acc48 {
doclose = NULL,
ws = (nil) {
{rxbuf_b, rxbuf_e} = {(nil), (nil)},
{pipeline_b, pipeline_e} = {(nil), (nil)},
content_length = 0,
body_status = none,
first_byte_timeout = 0.000000,
between_bytes_timeout = 0.000000,
http(req) = 0x7f5bc00aae10 {
ws = 0x7f5bc00aad70 {
(Already dumped, see above)
hdrs {
“X-Forwarded-Proto: https”,
“X-Forwarded-Port: 443”,
“Ssl-Offloaded: 1”,
“DBG-SSL: 1”,
“Connection: close”,
“user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36”,
“accept: /“,
“Accept-Encoding: gzip”,
“grace: none”,
vcl = {
name = “boot”,
busy = 3,
discard = 0,
state = auto,
temp = warm,
conf = {
srcname = {
vmods = {
std = {Varnish 6.1.1 efc2f6c1536cf2272e471f5cff5f145239b19460, 0.0},
flags = {
privs = 0x7f5bc00aadf8 {
thr.busyobj = (nil) {

Debug: Child cleanup complete

magento2 – Magento 2.4 Varnish error 503

I got a copy of my Magento in another server, all checked permissions, vanilla installation, domain, but I don’t find the issue, I keep seeing this error message below.

Error 503 Backend fetch failed
Backend fetch failed

I found this reference from Magento but didn’t work.

How could I fix it?

php – Storing session variable without interfering with Varnish

I have a form ( that submits to a 3rd party app to add users to a contact list. The vendor does not provide any means of using AJAX, rather they allow you to specify a URL to redirect to after the form has processed. In an effort to have the UX of using this archaic form come as possible to functioning like an AJAX-enabled form, I am specifying the same page the form is on as the redirect page. I need to make it such that if the user filled out the form, a confirmation page will be displayed and if not, the form itself is displayed.

I am currently adding a query string parameter to the redirect URL (through the 3rd party app), so it looks something like This way is easy enough to show the appropriate content (form or confirmation), but i don’t like the fact that someone could go to without filling out the form.

I had the idea of making an AJAX call onSubmit that would do something to the effect of:

// JavaScript

$('form').submit(function() {     
      url:  admin-ajax.php
      method: 'post',
      action: 'handle_ajax_submit'
    success: function() {
      return true;
    return false;

// PHP

function handle_ajax_submit() {
  if (!session_id()) {
  $_SESSION('form_submitted') = true;

I’d then use that value to determine which piece of content is displayed, form or confirmation. The problem with this is that my understanding is that the use of _SESSION prevents Varnish from caching the page, which i’d obviously like to avoid if possible.

Is there another”standard” way to handle this kind of situation in WordPress specifically? If not, would a standard cookie be the way to go here… or prhaps local storage? Both would require that AJAX call onSubmit, correct?

magento2 – Varnish cache always MISS on dynamic pages

Varnish doesn’t seem to be working properly for dynamic pages, it always returns a MISS in the response headers whether the request is coming from the browser or the CLI (curl/wget).

curl -IL -X GET ‘’

HTTP/1.1 200 OK
Date: Sun, 04 Oct 2020 10:45:45 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Set-Cookie: PHPSESSID=aqhdrf2kemsc2n6uvv0a4m1j51; expires=Sun, 04-Oct-2020 11:45:45 GMT; Max-Age=3600; path=/;; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Cache: MISS
Pragma: no-cache
Expires: -1
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Accept-Ranges: bytes
Content-Length: 23297
Connection: keep-alive

However requests on static assets do hit varnish as expected:

curl -IL -X GET ‘’

HTTP/1.1 200 OK
Date: Sun, 04 Oct 2020 10:36:06 GMT
Content-Type: image/svg+xml
Last-Modified: Sat, 03 Oct 2020 20:48:21 GMT
Vary: Accept-Encoding
ETag: W/"5f78e395-f43"
Expires: Mon, 04 Oct 2021 10:36:06 GMT
Cache-Control: max-age=31536000, public
X-Frame-Options: SAMEORIGIN
X-Cache: HIT
X-Cache-Hits: 14
Accept-Ranges: bytes
Content-Length: 3907
Connection: keep-alive

I added the X-Cache and X-Cache-Hits headers to debug in production mode. This is a pretty stock version of Magento with no custom modules and using the blank theme. My default.vcl file is pretty much stock “Varnish 6” settings exported from the backend except for enabling caching static files and the debug response headers I included.


# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
vcl 4.0;

import std;
# The minimal Varnish version is 6.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'

backend default {
    .host = "localhost";
    .port = "8080";
    .first_byte_timeout = 600s;
    .probe = {
        .url = "/health_check.php";
        .timeout = 2s;
        .interval = 5s;
        .window = 10;
        .threshold = 5;

acl purge {

sub vcl_recv {
    if (req.method == "PURGE") {
        if (client.ip !~ purge) {
            return (synth(405, "Method not allowed"));
        # To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
        # has been added to the response in your backend server config. This is used, for example, by the
        # capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
        if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
            return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
        if (req.http.X-Magento-Tags-Pattern) {
          ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
        if (req.http.X-Pool) {
          ban("obj.http.X-Pool ~ " + req.http.X-Pool);
        return (synth(200, "Purged"));

    if (req.method != "GET" &&
        req.method != "HEAD" &&
        req.method != "PUT" &&
        req.method != "POST" &&
        req.method != "TRACE" &&
        req.method != "OPTIONS" &&
        req.method != "DELETE") {
          /* Non-RFC2616 or CONNECT which is weird. */
          return (pipe);

    # We only deal with GET and HEAD by default
    if (req.method != "GET" && req.method != "HEAD") {
        return (pass);

    # Bypass shopping cart, checkout and search requests
    if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
        return (pass);

    # Bypass health check requests
    if (req.url ~ "/pub/health_check.php") {
        return (pass);

    # Set initial grace period usage status
    set req.http.grace = "none";

    # normalize url in case of leading HTTP scheme and domain
    set req.url = regsub(req.url, "^http(s)?://", "");

    # collect all cookies

    # Compression filter. See
    if (req.http.Accept-Encoding) {
        if (req.url ~ ".(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
            # 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" && req.http.user-agent !~ "MSIE") {
            set req.http.Accept-Encoding = "deflate";
        } else {
            # unknown algorithm
            unset req.http.Accept-Encoding;

    # Remove all marketing get parameters to minimize the cache objects
    if (req.url ~ "(?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_(a-z)+|utm_(a-z)+|_bta_(a-z)+)=") {
        set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_(a-z)+|utm_(a-z)+|_bta_(a-z)+)=(-_A-z0-9+()%.)+&?", "");
        set req.url = regsub(req.url, "(?|&)+$", "");

    # Static files caching
    if (req.url ~ "^/(pub/)?(media|static)/") {
        # Static files should not be cached by default
        #return (pass);

        # But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
        unset req.http.Https;
        unset req.http.X-Forwarded-Proto;
        unset req.http.Cookie;

    return (hash);

sub vcl_hash {
    if (req.http.cookie ~ "X-Magento-Vary=") {
        hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=((^;)+);*.*$", "1"));

    # For multi site configurations to not cache each other's content
    if ( {
    } else {

    # To make sure http users don't see ssl warning
    if (req.http.X-Forwarded-Proto) {

    if (req.url ~ "/graphql") {
        call process_graphql_headers;

sub process_graphql_headers {
    if (req.http.Store) {
    if (req.http.Content-Currency) {

sub vcl_backend_response {

    set beresp.grace = 3d;

    if (beresp.http.content-type ~ "text") {
        set beresp.do_esi = true;

    if (bereq.url ~ ".js$" || beresp.http.content-type ~ "text") {
        set beresp.do_gzip = true;

    if (beresp.http.X-Magento-Debug) {
        set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;

    # cache only successfully responses and 404s
    if (beresp.status != 200 && beresp.status != 404) {
        set beresp.ttl = 0s;
        set beresp.uncacheable = true;
        return (deliver);
    } elsif (beresp.http.Cache-Control ~ "private") {
        set beresp.uncacheable = true;
        set beresp.ttl = 86400s;
        return (deliver);

    # validate if we need to cache it and prevent from setting cookie
    if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
        unset beresp.http.set-cookie;

   # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
   if (beresp.ttl <= 0s ||
       beresp.http.Surrogate-control ~ "no-store" ||
       (!beresp.http.Surrogate-Control &&
       beresp.http.Cache-Control ~ "no-cache|no-store") ||
       beresp.http.Vary == "*") {
        # Mark as Hit-For-Pass for the next 2 minutes
        set beresp.ttl = 120s;
        set beresp.uncacheable = true;

    return (deliver);

sub vcl_deliver {
    if (resp.http.X-Magento-Debug) {
        if (resp.http.x-varnish ~ " ") {
            set resp.http.X-Magento-Cache-Debug = "HIT";
            set resp.http.Grace = req.http.grace;
        } else {
            set resp.http.X-Magento-Cache-Debug = "MISS";
    } else {
        unset resp.http.Age;

    if (obj.hits > 0) {
        set resp.http.X-Cache = "HIT";
        set resp.http.X-Cache-Hits = obj.hits;
    else {
        set resp.http.X-Cache = "MISS";

    # Not letting browser to cache non-static files.
    if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
        set resp.http.Pragma = "no-cache";
        set resp.http.Expires = "-1";
        set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";

    unset resp.http.X-Magento-Debug;
    unset resp.http.X-Magento-Tags;
    unset resp.http.X-Powered-By;
    unset resp.http.Server;
    unset resp.http.X-Varnish;
    unset resp.http.Via;
    unset resp.http.Link;

sub vcl_hit {
    if (obj.ttl >= 0s) {
        # Hit within TTL period
        return (deliver);
    if (std.healthy(req.backend_hint)) {
        if (obj.ttl + 300s > 0s) {
            # Hit after TTL expiration, but within grace period
            set req.http.grace = "normal (healthy server)";
            return (deliver);
        } else {
            # Hit after TTL and grace expiration
            return (restart);
    } else {
        # server is not healthy, retrieve from cache
        set req.http.grace = "unlimited (unhealthy server)";
        return (deliver);

Also my config settings in the backend:

Full Page Cache

Caching Application: Varnish Cache (Recommended)
TTL for public content: 86400
Access list: localhost
Backend host: localhost
Backend port: 8080
Grace period: 300

I checked the whole response XML and there’s no cacheable="false" being set, I found odd that the Cache-Control header is set to no-cache but that seems to be the behaviour the VCL file sets for non-static files by default.

Any advice on what to do?

magento2 – Setting varnish full page cache settings via environment variables

I’m trying to set the varnish settings through environmental variables. I have the following ones set:


If I go to the settings for Full Page Cache I can verify that it’s set to the above mentioned values. See image below.

full page cache settings

My problem comes when I’m trying to run bin/magento cache:clean. In my system.log I get the following error: main.CRITICAL: Unable to connect to varnish:80 . Error #0: stream_socket_client(): unable to connect to varnish:80. As you can see these values are not respected when cleaning the cache.

To solve this for now I need to run bin/magento setup:config:set --http-cache-hosts=varnish-service:8090 which solves the issue but I would still like Magento2 to respect the values I set through the environment variables so I can control it without running commands on the containers.

Magento version is 2.3.1 and I’m running my containers in Kubernetes.

How to add Varnish VCL rule in Magento Cloud?

I need to add a new VCL rule in my Magento Cloud 2.4, I’m using Fastly to have Varnish.

How could I customize my Varnish configurations in Magento?

Magento bitnami linux Setup Varnish

I want to configure and use :
for Magento in bitnami Linux

caching – Convert Acquia Clear Varnish For One URL Curl Command to Drupal::httpClient()

I am trying to convert a command to php curl or Drupal::httpClient().

The original command

Curl -k -X PURGE -H "X-Acquia-Purge:(site-name)" --compressed -H "Host:"

Here is the conversion I tried (but it is not working) This one returns 200 status code but it is not working.

$varnishUrl = ""
$headers = (
  'X-Acquia-Purge'  => "site-name",
  'Host'            => ""
$options = ('headers' => $headers, 'body' => $varnishUrl);
try {
  $client = Drupal::httpClient();
  $response = $client->request('PURGE', $domainUrl, $options);
  $code = $response->getStatusCode();
  if ($code == 200) {
    return $code;
catch (RequestException $e) {
  watchdog_exception('module_name', $e);

This is the second conversion to php and also not working.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $varnishUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers() = 'X-Acquia-Purge: site-name';
$headers() = 'Host:';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

I would appreciate any input.