Hi, after installing nginx as reverse proxy i noticed that some of website functions doesn't work anymore.
In a website i have this piece of code :
that redirects visitors to the login page if they aren't logged in, so only logged in users can browse shop pages.
I've also tried the same functionality with a plugin WooCommerce for Logged-in Users that does the same thing (i believe it uses the same code).
The problem is that users are always redirected to the login page even if they are logged in.
I believe that nginx is caching the redirect and users are always redirected to the login page.
When i clear the account's nginx cache via the "clear cache" button in user's cpanel it is working for a while, but soon it keeps redirecting users.
If i disable nginx cache for that user via WHM the code is working as expected.
Is there a way to fix this problem without disabling nginx cache for every user using such functionality?
I believe that at the end many users will have the nginx cache disabled and we will loose the benefits of using nginx.
best,
In a website i have this piece of code :
PHP:
//// SHOP PAGES ONLY FOR LOGGED IN USERS
function wdo_user_redirect() {
if (! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout())) {
wp_redirect('/my-account/');
exit;
}
}
add_action('template_redirect', 'wdo_user_redirect');
I've also tried the same functionality with a plugin WooCommerce for Logged-in Users that does the same thing (i believe it uses the same code).
The problem is that users are always redirected to the login page even if they are logged in.
I believe that nginx is caching the redirect and users are always redirected to the login page.
When i clear the account's nginx cache via the "clear cache" button in user's cpanel it is working for a while, but soon it keeps redirecting users.
If i disable nginx cache for that user via WHM the code is working as expected.
Is there a way to fix this problem without disabling nginx cache for every user using such functionality?
I believe that at the end many users will have the nginx cache disabled and we will loose the benefits of using nginx.
best,
Last edited: