varnish-nginx-wordpress icon indicating copy to clipboard operation
varnish-nginx-wordpress copied to clipboard

can't access to my admin ....

Open TOMER628 opened this issue 10 years ago • 16 comments

hi !

i using varnish 4.0 and Wordpress 4.1 i like your job it's awesome cache. but i have a problem to enter my admin area:

mywebsite.com/s-login

or another website:

mywebsite.com/tomer-login

he said : " You must log in to access the admin area. " and i am the admin , i don't how to fix that , before this Code of Default.vcl i was free access to my admin area without problem..

what i need to do to fix that ?

regards, Tomer

TOMER628 avatar Jan 01 '15 23:01 TOMER628

Hi, i default.vcl change :

# Did not cache the admin and login pages
if (req.url ~ "/wp-(login|admin)") {
    return (pass);
}

By :

# Did not cache the admin and login pages
if (req.url ~ "/(s-login|tomer-login|wp-login|wp-admin)") {
    return (pass);
}

You can remove wp-login and wp-admin if you don't use them. Regards.

Oyabi avatar Jan 01 '15 23:01 Oyabi

wow you fast ! i tried that now but still same error

anf if i delete Cookies from Chrome browser and after that i try to connect to admin area, he said this error:

ERROR: Cookies are blocked or not supported by your browser. Cookies must be enabled to use WordPress.

TOMER628 avatar Jan 01 '15 23:01 TOMER628

Have you custom the file varnish4-wordpress ? I remember that I have similary error and I think these lines resolve it :

# Remove the wp-settings-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");
# Remove the wp-settings-time-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");
# Remove the wp test cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");

I don't remember exactly which repair your problem but try to search all "cookie" occurence in varnish4-wordpress. =)

Oyabi avatar Jan 02 '15 00:01 Oyabi

so just add this line to code?

TOMER628 avatar Jan 02 '15 00:01 TOMER628

yep, look at varnish4-wordpress ;) https://github.com/nicolargo/varnish-nginx-wordpress/blob/master/varnish/varnish4-wordpress Maybe anothers lines must be add, but there all in example file ;)

Oyabi avatar Jan 02 '15 00:01 Oyabi

this exactly the code i copied ... and also i added this line into file right now ,and still error with cookies

TOMER628 avatar Jan 02 '15 00:01 TOMER628

by the way this:

Only allow purging from specific IPs

acl purge { "localhost"; "127.0.0.1"; }

i did not change the ip (127.0.0.1) this ok right ?

TOMER628 avatar Jan 02 '15 00:01 TOMER628

Sorry i haven't read all my file earlier. You must also ahve theses lines in sub vcl_backend_response :

# 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;
}

For your configuration you must change it to :

# Only allow cookies to be set if we're in admin area
if (beresp.http.Set-Cookie && bereq.url !~ "^/(s-login|tomer-login|wp-login|wp-admin)") {
   unset beresp.http.Set-Cookie;
}

I hope your error is gone. 127.0.0.1 and localhost are right in almost ever case ;)

Oyabi avatar Jan 02 '15 00:01 Oyabi

yes !!!!!! you did it !!!!

Great !

thank you so much

i think maybe you need to add this to your code .. i mean to add explain if someone (like me) change the login admin area..

TOMER628 avatar Jan 02 '15 00:01 TOMER628

It's in the file, but you must adapt it to correpond to your custom install. By default you can access wordpress admin with /wp-admin address. You modify it for use (s-login|tomer-login) so you must add this change in config file ;) Have a nice day.

Oyabi avatar Jan 02 '15 00:01 Oyabi

thank you so much i like your code it make my Wordpress fastest

TOMER628 avatar Jan 02 '15 00:01 TOMER628

hi again.. i forgot to ask: i need also this plugin (or your code do that automaticlly ? LINK: https://wordpress.org/plugins/varnish-http-purge/

TOMER628 avatar Jan 02 '15 09:01 TOMER628

No, you had to use this plugin in order to purge the cache (for exemple after an WP plugins update).

nicolargo avatar Jan 02 '15 10:01 nicolargo

SO the answer is not, right ?

TOMER628 avatar Jan 02 '15 10:01 TOMER628

Yes the answer is... not.

nicolargo avatar Jan 02 '15 15:01 nicolargo

THANKS

TOMER628 avatar Jan 03 '15 16:01 TOMER628