Magento2 Varnish + Cloudflare issue


I have tested Cloudflare on my Magento2 which uses by default Varnish.

When I tested Cloudflare, there was a problem with Varnish: any change I made on my website was not reflecting online anymore (I had to flush Varnish cache each time).

Is there something special to do so that Cloudflare & Varnish can work together ?

Basically, Varnish alone is working fine.
When I proxy my domain on Cloudflare, then the problem occurs.
When I set DNS only on Cloudflare, then it is working again.

So basically, Cloudflare prevent Varnish to refresh the page when needed, so the whole system is faulty.

Any help much appreciated


I am not familiar with Magento as with Varnish, but do you have Cloudflare module for Magento 2 installed?

Moreover, regarding the cache, could it be possible of your issue regarding cookies as written here?:


Thanks for your reply.

Oh sorry, I forgot to say that this:

has already been applied with no difference.

Looked at the second link, but my issue is a bit different: pages are cached with varnish without problem, it is just that with Cloudflare on, Varnish doesn’t refresh the content when it has to :frowning:

Thank you for feedback.
Moreover, have you tried to setup some Page Rules on the Cloudflare dashboard regarding the Varnish cache?

Not at all, should I ?
If yes, what should I parameter here ?


By the way, is Cloudflare compatible with Varnish ?

I don’t know what to do, I need Varnish.
Maybe there is something to adjust in the Varnish configuration to make it work with Cloudflare ?


My hosting company modified the backend default ip with my public IP instead of localhost. And they also modified the IP in the http-cache-hosts.
Now everything is good !

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.