Blame view

sources/core/doc/admin/configuration/xsendfile.html 15.1 KB
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
6
7
8
9
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
  
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      
6d9380f96   Cédric Dupont   Update sources OC...
10
      <title>Serving static files via web server &mdash; ownCloud Administrators Manual 7.0 documentation</title>
d1bafeea1   Kload   [fix] Upgrade to ...
11
12
13
14
15
16
17
18
19
      
      <link rel="stylesheet" href="../_static/style.css" type="text/css" />
      <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../_static/style.css" type="text/css" />
      <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
      
      <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../',
6d9380f96   Cédric Dupont   Update sources OC...
20
          VERSION:     '7.0',
d1bafeea1   Kload   [fix] Upgrade to ...
21
22
23
24
25
26
27
28
29
          COLLAPSE_INDEX: false,
          FILE_SUFFIX: '.html',
          HAS_SOURCE:  true
        };
      </script>
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>
      <script type="text/javascript" src="../_static/bootstrap.js"></script>
6d9380f96   Cédric Dupont   Update sources OC...
30
      <link rel="top" title="ownCloud Administrators Manual 7.0 documentation" href="../index.html" />
d1bafeea1   Kload   [fix] Upgrade to ...
31
      <link rel="up" title="Configuration" href="index.html" />
6d9380f96   Cédric Dupont   Update sources OC...
32
      <link rel="next" title="Maintenance" href="../maintenance/index.html" />
d1bafeea1   Kload   [fix] Upgrade to ...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
      <link rel="prev" title="Custom User Backend Configuration" href="custom_user_backend.html" />
  <script type="text/javascript">
  (function () {
    /**
     * Patch TOC list.
     *
     * Will mutate the underlying span to have a correct ul for nav.
     *
     * @param $span: Span containing nested UL's to mutate.
     * @param minLevel: Starting level for nested lists. (1: global, 2: local).
     */
    var patchToc = function ($ul, minLevel) {
      var findA;
  
      // Find all a "internal" tags, traversing recursively.
      findA = function ($elem, level) {
        var level = level || 0,
          $items = $elem.find("> li > a.internal, > ul, > li > ul");
  
        // Iterate everything in order.
        $items.each(function (index, item) {
          var $item = $(item),
            tag = item.tagName.toLowerCase(),
            pad = 15 + ((level - minLevel) * 10);
  
          if (tag === 'a' && level >= minLevel) {
            // Add to existing padding.
            $item.css('padding-left', pad + "px");
            console.log(level, $item, 'padding-left', pad + "px");
          } else if (tag === 'ul') {
            // Recurse.
            findA($item, level + 1);
          }
        });
      };
  
      console.log("HERE");
      findA($ul);
    };
  
    $(document).ready(function () {
      // Add styling, structure to TOC's.
      $(".dropdown-menu").each(function () {
        $(this).find("ul").each(function (index, item){
          var $item = $(item);
          $item.addClass('unstyled');
        });
        $(this).find("li").each(function () {
          $(this).parent().append(this);
        });
      });
  
      // Patch in level.
      patchToc($("ul.globaltoc"), 2);
      patchToc($("ul.localtoc"), 2);
  
      // Enable dropdown.
      $('.dropdown-toggle').dropdown();
    });
  }());
  </script>
  
    </head>
    <body>
    
  
  <div class="container">
    <div class="content">
      <div class="page-header">
        <h1><a href="../contents.html">ownCloud Administrators Manual</a></h1>
  
      </div>
      
  			<div class="row">
  				<div class="span3">
  					<div class="sidebar">
  						<div class="well">
  							<div class="menu-support-container">
  								<ul id="menu-support" class="menu">
  									<ul>
  										<li><a href="../contents.html">Overview</a></li>
  									</ul>
                    <ul>
6d9380f96   Cédric Dupont   Update sources OC...
116
  <li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
d1bafeea1   Kload   [fix] Upgrade to ...
117
118
119
120
  </ul>
  <ul class="current">
  <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a></li>
  <li class="toctree-l1 current"><a class="reference internal" href="index.html">Configuration</a><ul class="current">
6d9380f96   Cédric Dupont   Update sources OC...
121
  <li class="toctree-l2"><a class="reference internal" href="configuration_apps.html">Apps Configuration</a></li>
d1bafeea1   Kload   [fix] Upgrade to ...
122
  <li class="toctree-l2"><a class="reference internal" href="configuration_users.html">User Management</a></li>
6d9380f96   Cédric Dupont   Update sources OC...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  <li class="toctree-l2"><a class="reference internal" href="auth_ldap.html">User Authentication with LDAP</a></li>
  <li class="toctree-l2"><a class="reference internal" href="server_to_server_managing.html">Managing Server-to-Server Sharing Access</a></li>
  <li class="toctree-l2"><a class="reference internal" href="background_jobs.html">Defining Background Jobs</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_assets.html">Asset Management</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_3rdparty.html">Using Third Party Components</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_automation.html">Defining Automatic Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_custom_clients.html">Custom Client Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_database.html">Database Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_encryption.html">Use Server-Side Encryption</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_knowledgebase.html">Knowledge Base Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_language.html">Language Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_logging.html">Logging Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_mail.html">Mail Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuration_preview.html">Preview Configuration</a></li>
d1bafeea1   Kload   [fix] Upgrade to ...
137
  <li class="toctree-l2"><a class="reference internal" href="configuration_reverseproxy.html">Reverse Proxy Configuration</a></li>
6d9380f96   Cédric Dupont   Update sources OC...
138
139
140
  <li class="toctree-l2"><a class="reference internal" href="configuring_big_file_upload.html">Uploading big files &gt; 512MB (as set by default)</a></li>
  <li class="toctree-l2"><a class="reference internal" href="configuring_big_file_upload.html#enabling-uploading-big-files">Enabling uploading big files</a></li>
  <li class="toctree-l2"><a class="reference internal" href="custom_mount_config_gui.html">Custom Mount Configuration (GUI)</a></li>
d1bafeea1   Kload   [fix] Upgrade to ...
141
142
143
144
145
146
147
148
149
150
151
  <li class="toctree-l2"><a class="reference internal" href="custom_mount_config.html">Custom Mount Configuration</a></li>
  <li class="toctree-l2"><a class="reference internal" href="custom_user_backend.html">Custom User Backend Configuration</a></li>
  <li class="toctree-l2 current"><a class="current reference internal" href="">Serving static files via web server</a><ul>
  <li class="toctree-l3"><a class="reference internal" href="#apache2-x-sendfile">Apache2 (X-Sendfile)</a></li>
  <li class="toctree-l3"><a class="reference internal" href="#lighttpd-x-sendfile2">LigHTTPd (X-Sendfile2)</a></li>
  <li class="toctree-l3"><a class="reference internal" href="#nginx-x-accel-redirect">Nginx (X-Accel-Redirect)</a></li>
  <li class="toctree-l3"><a class="reference internal" href="#how-to-check-if-it-s-working">How to check if it&#8217;s working?</a></li>
  </ul>
  </li>
  </ul>
  </li>
d1bafeea1   Kload   [fix] Upgrade to ...
152
  <li class="toctree-l1"><a class="reference internal" href="../maintenance/index.html">Maintenance</a></li>
d1bafeea1   Kload   [fix] Upgrade to ...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  <li class="toctree-l1"><a class="reference internal" href="../issues/index.html">Issues</a></li>
  </ul>
  
  								</ul>
  							</div>
  						</div>
  					</div>
  				</div>
          
  
  				<div class="span9">
  					<div class="page-content">
  						
    <div class="section" id="serving-static-files-via-web-server">
  <h1>Serving static files via web server<a class="headerlink" href="#serving-static-files-via-web-server" title="Permalink to this headline">¶</a></h1>
  <p>Since ownCloud 5 it is possible to let web servers handle static file serving.
  This should generally improve performance (web servers are optimized for this) and in some cases permits controlled
  file serving (i.e. pause and resume downloads).</p>
  <div class="admonition note">
  <p class="first admonition-title">Note</p>
6d9380f96   Cédric Dupont   Update sources OC...
173
174
  <p class="last">This feature can currently only be activated for local files, i.e. files inside the <strong>data/</strong> directory and local mounts.  It also does not work with the Encryption App enabled.
  Controlled file serving <strong>does not work for generated zip files</strong>. This is due to zip files being generated and streamed back directly to the client.</p>
d1bafeea1   Kload   [fix] Upgrade to ...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
  </div>
  <div class="section" id="apache2-x-sendfile">
  <h2>Apache2 (X-Sendfile)<a class="headerlink" href="#apache2-x-sendfile" title="Permalink to this headline">¶</a></h2>
  <p>It is possible to let Apache handle static file serving via <a class="reference external" href="https://tn123.org/mod_xsendfile/">mod_xsendfile</a>.</p>
  <div class="section" id="installation">
  <h3>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h3>
  <p>On Debian and Ubuntu systems use:</p>
  <div class="highlight-bash"><div class="highlight"><pre>apt-get install libapache2-mod-xsendfile
  </pre></div>
  </div>
  </div>
  <div class="section" id="configuration">
  <h3>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h3>
  <p>Configuration of mod_xsendfile for ownCloud depends on its version.
  For versions below 0.10 (Debian squeeze ships with 0.9)</p>
  <div class="highlight-xml"><pre>&lt;Directory /var/www/owncloud&gt;
      ...
      SetEnv MOD_X_SENDFILE_ENABLED 1
      XSendFile On
      XSendFileAllowAbove On
  &lt;/Directory&gt;</pre>
  </div>
  <p>For versions &gt;=0.10 (e.g. Ubuntu 12.10)</p>
  <div class="highlight-xml"><pre>&lt;Directory /var/www/owncloud&gt;
      ...
      SetEnv MOD_X_SENDFILE_ENABLED 1
      XSendFile On
d1bafeea1   Kload   [fix] Upgrade to ...
202
203
204
205
206
207
      XSendFilePath /home/valerio
  &lt;/Directory&gt;</pre>
  </div>
  <ul class="simple">
  <li><strong>SetEnv MOD_X_SENDFILE_ENABLED</strong>: tells ownCloud scripts that they should add the X-Sendfile header when serving files</li>
  <li><strong>XSendFile</strong>: enables web server handling of X-Sendfile headers (and therefore file serving) for the specified Directory</li>
6d9380f96   Cédric Dupont   Update sources OC...
208
209
  <li><strong>XSendFileAllowAbove (&lt;0.10)</strong>: enables file serving through web server on path outside the specified Directory. This is needed for configured local mounts which may reside outside data directory</li>
  <li><strong>XSendFilePath (&gt;=0.10)</strong>: a white list of paths that the web server is allowed to serve outside of the specified Directory. Other paths which correspond to local mounts should be configured here as well. For a more in-depth documentation of this directive refer to mod_xsendfile website linked above</li>
d1bafeea1   Kload   [fix] Upgrade to ...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  </ul>
  </div>
  </div>
  <div class="section" id="lighttpd-x-sendfile2">
  <h2>LigHTTPd (X-Sendfile2)<a class="headerlink" href="#lighttpd-x-sendfile2" title="Permalink to this headline">¶</a></h2>
  <p>LigHTTPd uses similar headers to Apache2, apart from the fact that it does not handle partial downloads in the same way
  Apache2 does. For this reason, a different method is used for LigHTTPd.</p>
  <div class="section" id="id1">
  <h3>Installation<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
  <p>X-Sendfile and X-Sendfile2 are supported by default in LigHTTPd and no additional operation should be needed to install it.</p>
  </div>
  <div class="section" id="id2">
  <h3>Configuration<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
  <p>Your server configuration should include the following statements:</p>
  <div class="highlight-python"><pre>fastcgi.server          = ( ".php" =&gt; ((
     ...
     "allow-x-send-file" =&gt; "enable",
     "bin-environment" =&gt; (
        "MOD_X_SENDFILE2_ENABLED" =&gt; "1",
     ),
  )))</pre>
  </div>
  <ul class="simple">
  <li><strong>allow-x-send-file</strong>: enables LigHTTPd to use X-Sendfile and X-Sendfile2 headers to serve files</li>
  <li><strong>bin-environment</strong>: is used to parse MOD_X_SENDFILE2_ENABLED to the ownCloud backend, to make it use the X-Sendfile and X-Sendfile2 headers in it&#8217;s response</li>
  </ul>
  </div>
  </div>
  <div class="section" id="nginx-x-accel-redirect">
  <h2>Nginx (X-Accel-Redirect)<a class="headerlink" href="#nginx-x-accel-redirect" title="Permalink to this headline">¶</a></h2>
  <p>Nginx supports handling of static files differently from Apache. Documentation can be found in the Nginx Wiki
  section <a class="reference external" href="http://wiki.nginx.org/XSendfile">Mod X-Sendfile</a> and section <a class="reference external" href="http://wiki.nginx.org/X-accel">X-Accell</a>.
  The header used by Nginx is X-Accel-Redirect.</p>
  <div class="section" id="id3">
  <h3>Installation<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
  <p>X-Accel-Redirect is supported by default in Nginx and no additional operation should be needed to install it.</p>
  </div>
  <div class="section" id="id4">
  <h3>Configuration<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
  <p>Configuration is similar to Apache:</p>
6d9380f96   Cédric Dupont   Update sources OC...
250
  <div class="highlight-python"><pre>location ~ \.php(?:$|/) {
d1bafeea1   Kload   [fix] Upgrade to ...
251
252
253
      ...
      fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
  }
6d9380f96   Cédric Dupont   Update sources OC...
254
  location ^~ /data {
d1bafeea1   Kload   [fix] Upgrade to ...
255
      internal;
6d9380f96   Cédric Dupont   Update sources OC...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
      # Set 'alias' if not using the default 'datadirectory'
      #alias /path/to/non-default/datadirectory;
  
  #    LOCAL-MOUNT-NAME should match "Folder name" and 'alias' value should match "Configuration"
  #    A 'Local' External Storage Mountpoint available to a single user
  #    location /data/USER/files/LOCAL-FS-MOUNT-NAME {
  #        alias /path/to/local-mountpoint;
  #    }
  
  #    A 'Local' External Storage Mountpoint available to mulitple users
  #    location ~ ^/data/(?:USER1|USER2)/files/LOCAL-FS-MOUNT-NAME/(.+)$ {
  #        alias /path/to/local-mountpoint/$1;
  #    }
  
  #    A 'Local' External Storage Mountpoint available to all users
  #    location ~ ^/data/[^/]+/files/LOCAL-FS-MOUNT-NAME/(.+)$ {
  #        alias /path/to/local-mountpoint/$1;
  #    }
d1bafeea1   Kload   [fix] Upgrade to ...
274

d1bafeea1   Kload   [fix] Upgrade to ...
275
276
277
  }</pre>
  </div>
  <ul class="simple">
6d9380f96   Cédric Dupont   Update sources OC...
278
279
280
281
282
283
  <li><strong>fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED</strong> ~ Tells ownCloud scripts that they should add the X-Accel-Redirect header when serving files.</li>
  <li><strong>/data</strong> ~ The ownCloud data directory.  Any &#8216;Local&#8217; External Storage Mounts must also have nested locations here.<ul>
  <li>set alias if you are using a non-default data directory</li>
  <li><strong>/data/USER/files/LOCAL-MOUNT-NAME</strong> ~ a local external storage mount available to a single user</li>
  <li><strong>~ ^/data/(?:USER1|USER2)/files/LOCAL-MOUNT-NAME/(.+)$</strong> ~ a local external storage mount available to multiple users</li>
  <li><strong>~ ^/data/[^/]+/files/LOCAL-MOUNT-NAME/(.+)$</strong> ~ a local external storage mount available to all users</li>
d1bafeea1   Kload   [fix] Upgrade to ...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
  </ul>
  </li>
  </ul>
  </div>
  </div>
  <div class="section" id="how-to-check-if-it-s-working">
  <h2>How to check if it&#8217;s working?<a class="headerlink" href="#how-to-check-if-it-s-working" title="Permalink to this headline">¶</a></h2>
  <p>You are still able to download stuff via the web interface and single, local file downloads can be paused and resumed.</p>
  </div>
  </div>
  
  
  					</div>
  				</div>
  			</div>
      
    </div>
  </div>
    </body>
  </html>