0

Hi I've been trying to figure this out for quite some time now, but whatever I do nothing seem to work.

I have a VPS setup running Nginx + Varnish with WordPress multisite.

Everything works fine except the admin/toolbar when browsing the sites. It simply wont load. It loads in the admin area, but when viewing site it doesn't load.

I have checked the "Show Toolbar when viewing site", and I have deactivated all plugins.

Now I have even gone so far as of creating a brand new WP install running only the default stuff, just to see if that works, but still the bar wont show.

I have checked the source code and the strange thing is that the "#wpadminbar" isn't there! But since this is the default theme every code looks fine - wp_head & wp_footer is correctly placed.

My guess now is that this is more a server problem, and maybe a Nginx or Varnish issue?

I hope someone can help me figure this out...

-Howie

4
  • 1
    Most likely the non-logged-in visitors are generating the cached versions of your pages without the admin bar.
    – birgire
    Commented Sep 11, 2013 at 10:32
  • @birgire is probably right. Please post your entire varnish conf to see if everything is okay in it. Commented Sep 11, 2013 at 14:47
  • @birgire, any suggestion on how to fix this? I have tried to restart varnish and to clear cache but nothing seem to work...
    – vpsnewbie
    Commented Sep 12, 2013 at 10:33
  • this is probably because varnish is caching and serving all frontend requests and you're getting the same cached pages logged out users do when you visit the frontend. You'll need to adjust Nginx/varnish to not serve/use varnish when login cookies are set
    – Tom J Nowell
    Commented Sep 30, 2022 at 16:27

2 Answers 2

0

If you're using Varnish and you're not seeing the admin bar it's because you probably have a rule in /etc/varnish/default.vcl that looks like this:

sub vcl_recv {
    if (!(req.url ~ "wp-(login|admin)")) {
        unset req.http.cookie;
    }
}

That's going to keep the admin bar from showing up because you're dropping cookie stuff from all pages except ones that match wp-(login|admin). As a test, try removing this and loading your site. If the admin bar shows up, you will want to adjust your Varnish rules.

There are a few different ways of handling things and it varies. You can check for a specific cookie name, URL strings, etc.

0

I was having the same problem so I updated my /etc/varnish/default.vcl to this - hard to say if I'm maybe now allowing too many cookies in (? I'll probably only use this on staging rather than production) but it got me my toolbar back!

# Drop any unnecessary cookies sent to Wordpress.
sub vcl_recv {
   // pages that require cookies
   if ((req.url ~ "^/sqlstuff") || (req.url ~ "wp-(login|admin)")) {
       return (pass);
   }

   // unset any cookies we don't want to keep
   if (req.http.cookie && !(req.http.cookie ~ "(wordpress_|wp-settings-)")) {
       unset req.http.cookie;
   }
}

# Drop any unnecessary cookies Wordpress tries to send back to the client.
sub vcl_fetch {
   // pages that require cookies
   if ((req.url ~ "^/sqlstuff") || (req.url ~ "wp-(login|admin)")) {
       return (hit_for_pass);
   }

   // unset any cookies we don't want to keep
   if (req.http.cookie && !(req.http.cookie ~ "(wordpress_|wp-settings-)")) {
       unset beresp.http.set-cookie;
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.