[Pkg-owncloud-commits] [owncloud-doc] 14/56: Update nginx cache purge to be multi user proof

David Prévot taffit at moszumanska.debian.org
Sun Nov 15 22:37:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud-doc.

commit 314fa85b321eda821087930371e440022d833933
Author: Martin <martin.mattel at diemattels.at>
Date:   Tue Oct 27 19:22:34 2015 +0100

    Update nginx cache purge to be multi user proof
    
    Conflicts:
    	admin_manual/configuration_server/performance_tuning/webserver_tips.rst
---
 .../performance_tuning/webserver_tips.rst          | 66 ++++++++++++++--------
 1 file changed, 43 insertions(+), 23 deletions(-)

diff --git a/admin_manual/configuration_server/performance_tuning/webserver_tips.rst b/admin_manual/configuration_server/performance_tuning/webserver_tips.rst
index 985ac0b..4b1ee51 100644
--- a/admin_manual/configuration_server/performance_tuning/webserver_tips.rst
+++ b/admin_manual/configuration_server/performance_tuning/webserver_tips.rst
@@ -24,7 +24,8 @@ server usage it is recommended to raise this number to a higher value.
 Enable the SPDY / http_v2 protocol
 ----------------------------------
 
-Your webserver can be configured to use the SPDY / http_v2 protocol which could improve 
+Your webserver can be configured to use the SPDY / http_v2 protocol which could 
+improve 
 the overall performance of ownCloud. Please have a look at the documentation of 
 your webservers module for more information:
 
@@ -32,8 +33,10 @@ your webservers module for more information:
 Webserver             Module Name / Link
 ====================  ==================
 Apache                `mod-spdy <https://code.google.com/p/mod-spdy/>`_
-nginx (<1.9.5)        `ngx_http_spdy_module <http://nginx.org/en/docs/http/ngx_http_spdy_module.html>`_
-nginx (+1.9.5)        `ngx_http_http2_module <http://nginx.org/en/docs/http/ngx_http_v2_module.html>`_
+nginx (<1.9.5)        `ngx_http_spdy_module 
+<http://nginx.org/en/docs/http/ngx_http_spdy_module.html>`_
+nginx (+1.9.5)        `ngx_http_http2_module 
+<http://nginx.org/en/docs/http/ngx_http_v2_module.html>`_
 ====================  ==================
 
 .. note:: If you want to enable SPDY for Apache please note the `Known Issues 
@@ -45,9 +48,11 @@ nginx (+1.9.5)        `ngx_http_http2_module <http://nginx.org/en/docs/http/ngx_
    1.) be aware that this module is not built in by default due to a dependency 
    to the openssl version used on your system. It will be enabled with the 
    ``--with-http_v2_module`` configuration parameter during compilation. The 
-   dependency should be checked automatically. You can check the presence of http_v2
+   dependency should be checked automatically. You can check the presence of 
+http_v2
    with ``nginx -V 2>&1 | grep http_v2 -o``. An example how to compile nginx can
-   be found in section "Configure Nginx with the ``nginx-cache-purge`` module" below.
+   be found in section "Configure Nginx with the ``nginx-cache-purge`` module" 
+below.
    
    2.) When you have used SPDY before, the nginx config has to be changed from 
    ``listen 443 ssl spdy;`` to ``listen 443 ssl http2;``
@@ -172,7 +177,8 @@ Compile Nginx with the ``nginx-cache-purge`` module
     sudo apt-key add nginx_signing.key
     sudo vi /etc/apt/sources.list.d/nginx.list
     
-Add the following lines (if different, replace ``{trusty}`` by your distribution 
+Add the following lines (if different, replace ``{trusty}`` by your 
+distribution 
  
 name)::
 
@@ -273,7 +279,7 @@ Configure Nginx with the ``nginx-cache-purge`` module
 1. **Preparation**
    Create a directory where Nginx will save the cached thumbnails. Use any 
    path that fits to your environment. Replace ``{path}`` in this example with 
-   your file path:
+   your path created:
    
 .. code-block:: bash   
    
@@ -284,25 +290,37 @@ Configure Nginx with the ``nginx-cache-purge`` module
 .. code-block:: bash
 
    sudo vi /etc/nginx/sites-enabled/{your-ownCloud-nginx-config-file}
-    
+   
 Add at the *beginning*, but *outside* the ``server{}`` block::
 
+   # cache_purge
    fastcgi_cache_path {path} levels=1:2 keys_zone=OWNCLOUD:100m inactive=60m;
+   map $request_uri $skip_cache {
+        default 1;
+        ~*/thumbnail.php 0;
+        ~*/apps/galleryplus/ 0;
+        ~*/apps/gallery/ 0;
+   }
+
+.. note:: Please adopt or delete any regex line in the ``map`` block according 
+   your needs and the ownCloud version used.
+.. note:: As an alternative to mapping, you can use as many ``if`` statements 
+in 
+   your server block as necessary::
    
+    set $skip_cache 1;
+    if ($request_uri ~* "thumbnail.php")      { set $skip_cache 0; }
+    if ($request_uri ~* "/apps/galleryplus/") { set $skip_cache 0; }
+    if ($request_uri ~* "/apps/gallery/")     { set $skip_cache 0; }
+
 Add *inside* the ``server{}`` block, as an example of a configuration::
    
-   set $skip_cache 1;
-       
-   # POST requests and urls with a query string should always go to PHP
-    
-   if ($request_uri ~* "thumbnail.php") 
-   { set $skip_cache 0;
-   }
-       
-   fastcgi_cache_key "$scheme$request_method$host$request_uri";
+   
+   # cache_purge (with $http_cookies we have unique keys for the user)
+   fastcgi_cache_key $http_cookie$request_method$host$request_uri;
    fastcgi_cache_use_stale error timeout invalid_header http_500;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
-       
+   
    location ~ \.php(?:$/) {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
        
@@ -312,28 +330,30 @@ Add *inside* the ``server{}`` block, as an example of a configuration::
          fastcgi_param HTTPS on;
          fastcgi_pass php-handler;
        
+         # cache_purge
          fastcgi_cache_bypass $skip_cache;
          fastcgi_no_cache $skip_cache;
          fastcgi_cache OWNCLOUD;
          fastcgi_cache_valid  60m;
+         fastcgi_cache_methods GET HEAD;
          }
    
-.. note: Note regarding the ``fastcgi_pass`` parameter:
+.. note:: Note regarding the ``fastcgi_pass`` parameter:
    Use whatever fits your configuration. In the example above, an ``upstream`` 
    was defined in an Nginx global configuration file.
-   This then can look like::
+   This may look like::
        
      upstream php-handler {
-         server 127.0.0.1:9000;
+         server unix:/var/run/php5-fpm.sock;
          # or
-         #server unix:/var/run/php5-fpm.sock;
+         # server 127.0.0.1:9000;
        } 
    
 3. **Test the configuration**
 
 .. code-block:: bash
 
-   sudo service nginx restart
+   sudo nginx -s reload
    
 *  Open your browser and clear your cache.   
 *  Logon to your ownCloud instance, open the gallery app, move thru your       

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git



More information about the Pkg-owncloud-commits mailing list