From 5e48cb07faa26b5485ad466691ec44b87b1630c4 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 4 Mar 2019 11:39:04 +0100 Subject: [PATCH] add fastcgi-cache mapping --- wo/cli/plugins/stack.py | 8 ++++++ wo/cli/templates/fastcgi-cache.mustache | 38 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 wo/cli/templates/fastcgi-cache.mustache diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 16b0dea..7ea9250 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -253,6 +253,14 @@ class WOStackController(CementBaseController): self.app.render((data), 'upstream.mustache', out=wo_nginx) wo_nginx.close() + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/conf.d/map-wp-fastcgi-cache.conf') + wo_nginx = open('/etc/nginx/conf.d/map-wp-fastcgi-cache.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'fastcgi-cache.mustache', + out=wo_nginx) + wo_nginx.close() + # Setup Nginx common directory if not os.path.exists('/etc/nginx/common'): Log.debug(self, 'Creating directory' diff --git a/wo/cli/templates/fastcgi-cache.mustache b/wo/cli/templates/fastcgi-cache.mustache new file mode 100644 index 0000000..7dc99c2 --- /dev/null +++ b/wo/cli/templates/fastcgi-cache.mustache @@ -0,0 +1,38 @@ +# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION +# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE +map $http_x_requested_with $http_request_no_cache { + default 0; + XMLHttpRequest 1; +} +map $http_cookie $cookie_no_cache { + default 0; + "~*wordpress_[a-f0-9]+" 1; + "~*wp-postpass" 1; + "~*wordpress_logged_in" 1; + "~*wordpress_no_cache" 1; + "~*comment_author" 1; + "~*woocommerce_items_in_cart" 1; + "~*woocommerce_cart_hash" 1; + "~*wptouch_switch_toogle" 1; + "~*comment_author_email_" 1; +} +map $request_uri $uri_no_cache { + default 0; + "~*/wp-admin/" 1; + "~*/wp-[a-zA-Z0-9-]+.php" 1; + "~*/feed/" 1; + "~*/index.php" 1; + "~*/[a-z0-9_-]+-sitemap([0-9]+)?.xml" 1; + "~*/sitemap(_index)?.xml" 1; + "~*/wp-comments-popup.php" 1; + "~*/wp-links-opml.php" 1; + "~*/xmlrpc.php" 1; +} +map $is_args $query_no_cache { + default 1; + "" 0; +} +map $http_request_no_cache$cookie_no_cache$uri_no_cache$query_no_cache $skip_cache { + default 1; + 0000 0; +}