Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save khangvm53/4e51c98d563e45f11f38224108bf544c to your computer and use it in GitHub Desktop.
Save khangvm53/4e51c98d563e45f11f38224108bf544c to your computer and use it in GitHub Desktop.
Varnish for Wordpress - Cookies are blocked or not supported
  • Find beresp.http.Set-Cookie and change it like the below
# Only allow cookies to be set if we're in admin area
	if (beresp.http.Set-Cookie && bereq.url !~ "/wp-(login|admin)") {
        	unset beresp.http.Set-Cookie;
    	}
  • The way forward cookie in varnish
# Drop any cookies sent to Wordpress.
sub vcl_recv {
	if (!(req.url ~ "wp-(login|admin)")) {
		unset req.http.cookie;
	}
}

# Drop any cookies Wordpress tries to send back to the client.
sub vcl_fetch {
	if (!(req.url ~ "wp-(login|admin)")) {
		unset beresp.http.set-cookie;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment