Skip to content

Running magento and varnish in kubernetes

Our M2 store is in development and we are in the process of adding Varnish enterprise.

Magento is installed in its own namespace in Kubernetes called m2-dev and varnish is in another namespace called m2-dev-varnish.

For now, I have a basic VCL just to get this infrastructure up and running.

vcl 4.1;

import std;

backend default {
    .host = "magento.m2-dev.svc.cluster.local";
    .port = "80";
}    

sub vcl_backend_fetch {
    set bereq.http.Host = "magento.m2-dev.svc.cluster.local";
}

However this results in a redirect loop and I cannot access my store or admin panel. I am not sure if the hostname mismatch causes the loop {“magento.m2-dev.svc.cluster.local” vs “dev.mydomain.com”} or if is caused by http/https? I have tried loads of different things but nothing has worked so far.

One thing that I did try was setting Auto-redirect to Base URL to no. This gave me access to my store but not my admin panel. The header on my store also disappeared

Is anyone able to help me debug?