Current File : //opt/alt/ruby19/lib64/ruby/gems/1.9.1/doc/rack-1.6.4/ri/Rack/Sendfile/cdesc-Sendfile.ri |
U:RDoc::NormalClass[iI"
Sendfile:EFI"Rack::Sendfile;FI"Object;Fo:RDoc::Markup::Document:@parts[o;;[)S:RDoc::Markup::Heading:
leveli: textI"
Sendfile;Fo:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"EThe Sendfile middleware intercepts responses whose body is being;FI"Iserved from a file and replaces it with a server specific X-Sendfile;FI"Mheader. The web server is then responsible for writing the file contents;FI"Lto the client. This can dramatically reduce the amount of work required;FI"Oby the Ruby backend and takes advantage of the web server's optimized file;FI"delivery code.;F@o;
;[I"JIn order to take advantage of this middleware, the response body must;FI"Irespond to +to_path+ and the request must include an X-Sendfile-Type;FI"Kheader. Rack::File and other components implement +to_path+ so there's;FI"Lrarely anything you need to do in your application. The X-Sendfile-Type;FI"Mheader is typically set in your web servers configuration. The following;FI"!sections attempt to document;F@S; ;
i;I"
Nginx;F@o;
;[I"NNginx supports the X-Accel-Redirect header. This is similar to X-Sendfile;FI"Ibut requires parts of the filesystem to be mapped into a private URL;FI"hierarchy.;F@o;
;[I"KThe following example shows the Nginx configuration required to create;FI"La private "/files/" area, enable X-Accel-Redirect, and pass the special;FI"@X-Sendfile-Type and X-Accel-Mapping headers to the backend:;F@o:RDoc::Markup::Verbatim;[I"location ~ /files/(.*) {
;FI" internal;
;FI" alias /var/www/$1;
;FI"}
;FI"
;FI"location / {
;FI" proxy_redirect off;
;FI"
;FI"5 proxy_set_header Host $host;
;FI"< proxy_set_header X-Real-IP $remote_addr;
;FI"J proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
;FI"
;FI"@ proxy_set_header X-Sendfile-Type X-Accel-Redirect;
;FI"A proxy_set_header X-Accel-Mapping /var/www/=/files/;
;FI"
;FI"2 proxy_pass http://127.0.0.1:8080/;
;FI"}
;Fo;
;[
I"MNote that the X-Sendfile-Type header must be set exactly as shown above.;FI"OThe X-Accel-Mapping header should specify the location on the file system,;FI"Mfollowed by an equals sign (=), followed name of the private URL pattern;FI"Jthat it maps to. The middleware performs a simple substitution on the;FI"resulting path.;F@o;
;[I"9See Also: http://wiki.codemongers.com/NginxXSendfile;F@S; ;
i;I"
lighttpd;F@o;
;[I"LLighttpd has supported some variation of the X-Sendfile header for some;FI"Mtime, although only recent version support X-Sendfile in a reverse proxy;FI"configuration.;F@o;;[I"&$HTTP["host"] == "example.com" {
;FI"% proxy-core.protocol = "http"
;FI", proxy-core.balancer = "round-robin"
;FI" proxy-core.backends = (
;FI" "127.0.0.1:8000",
;FI" "127.0.0.1:8001",
;FI" ...
;FI"
)
;FI"
;FI"/ proxy-core.allow-x-sendfile = "enable"
;FI"' proxy-core.rewrite-request = (
;FI"6 "X-Sendfile-Type" => (".*" => "X-Sendfile")
;FI"
)
;FI" }
;Fo;
;[I"JSee Also: http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModProxyCore;F@S; ;
i;I"Apache;F@o;
;[I"FX-Sendfile is supported under Apache 2.x using a separate module:;F@o;
;[I"%https://tn123.org/mod_xsendfile/;F@o;
;[I"GOnce the module is compiled and installed, you can enable it using;FI" XSendFile config directive:;F@o;;[I"2RequestHeader Set X-Sendfile-Type X-Sendfile
;FI"/ProxyPassReverse / http://localhost:8001/
;FI"XSendFile on
;FS; ;
i;I"Mapping parameter;F@o;
;[ I"BThe third parameter allows for an overriding extension of the;FI"QX-Accel-Mapping header. Mappings should be provided in tuples of internal to;FI"Nexternal. The internal values may contain regular expression syntax, they;FI",will be matched with case indifference.;F:
@fileI"lib/rack/sendfile.rb;F;0[ [[I"F;Fo;;[ ;0@}[ [[I"
class;F[[:public[[I"new;F@}[:protected[ [:private[ [I"
instance;F[[;[[I" call;F@}[;[ [;[