openbridge / nginx

NGINX Accelerated! This is a Docker image that creates a high performance (FAST!), optimized image for NGINX for use with Redis and PHP-FMP. Deliver sites and applications with performance, reliability, security, and scale. This NGINX server offers advanced performance, web and mobile acceleration, security controls, application monitoring, and management.
https://www.openbridge.com/
MIT License
233 stars 53 forks source link

nginx cache logged users #43

Closed lamariabdo closed 5 years ago

lamariabdo commented 5 years ago

Hello @tspicer

Please how can i prevent nginx for not cache page with users logged in because admin bar cache with page.

I use default openbridge/nginx configuration for nginx.

Can you help me fix it i would appreciate your help thank you.

tspicer commented 5 years ago

Logged in users to what? This is an Nginx service so there is no login. Are you describing another application outside of NGINX?

lamariabdo commented 5 years ago

Thank you for your reply,

logged users in wp-admin. for example if i login to wp-admin the admin bar cache with homepage. and please how i can purge cache with curl? i run this command and its not work curl "https://localhost/purge/"

tspicer commented 5 years ago

What have you tried to solve this? Just trying to purge? Have you googled how to stop this from happening? This is likely less of a PHP thing and more a cookie thing. This is not a Wordpress support channel so I don't have the time right now to troubleshoot a Wordpress install. If you search around there are a few pathways you can take to solve this in your configs.

lamariabdo commented 5 years ago

Hello, i add this my vhost conf but still not work

location / {

    set $no_cache 0;

    if ($request_method = POST) {
            set $no_cache 1;
    }
    if ($query_string != "") {
      set $no_cache 1;
    }

    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
      set $no_cache 1;
    }

    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
      set $no_cache 1;
    }

    proxy_pass                    http://proxy/;
    proxy_redirect                / /;

    error_page                    502 =200 @failed;
    proxy_cache_bypass            $http_pragma $no_cache $cookie_nocache $arg_nocache;
    proxy_no_cache                $no_cache ;

  }
tspicer commented 5 years ago

Is there a reason for overriding the $no_cache configuration? There is a map for $no_cache set in the nginx.conf file

    map   $request_uri $no_cache {include /etc/nginx/map.d/nocache/*.map;}

I would suggest creating a modified or new map ie map $http_cookie $no_cache and then correctly configure your context blocks.

tspicer commented 5 years ago

I updated a map that shows you how this should be done. Since I can't recreate your environment, I can't test this for you. However, this is in keeping with the config pattern. I'm sure you can learn from here if it does not work out of the box for you.

    map      $request_uri $no_cache {include /etc/nginx/map.d/nocache/nocache.map;}
    map      $http_cookie $no_cache {include /etc/nginx/map.d/nocache/cookie.map;}

This is in conf/php only.

lamariabdo commented 5 years ago

@tspicer Thank's i will check this.

i have a question please. how to change Memory limit, Max execution time, Max input vars ? i'm using ob_php-fpm. there is only PHP_MEMORY_LIMIT in the env file.

lamariabdo commented 5 years ago

@tspicer

It's work Thank you so much !!

one last thing please, there is any way to override **Max execution time, Max input vars** without touch in php-pfm conf? like .user.ini i tried this but it's not work any suggestion?

tspicer commented 5 years ago

Just mount your own config for php.

lamariabdo commented 5 years ago

i fixed it, thank you.

lamariabdo commented 5 years ago

@tspicer hello, sorry i have a problem, i'm running openbridge/nginx on centos 7 he doesn't have user/group www-data by default, I get permission denied when I try to edit a file.