non-standard HTTP header supported by Apache to offload the process of serving large static files from dynamic scripts (eg: PHP, Python, Perl) after they have performed the necessary authorization or restriction logic.
Questions tagged [x-sendfile]
155 questions
107
votes
8 answers
Fastest Way to Serve a File Using PHP
I'm trying to put together a function that receives a file path, identifies what it is, sets the appropriate headers, and serves it just like Apache would.
The reason I am doing this is because I need to use PHP to process some information about the…

Kirk Ouimet
- 27,280
- 43
- 127
- 177
39
votes
3 answers
In Ruby on Rails, After send_file method delete the file from server
I am using following code for sending the file in Rails.
if File.exist?(file_path)
send_file(file_path, type: 'text/excel')
File.delete(file_path)
end
In this I am trying to send the file and delete the file from server once it is been send…

Chetan Kalore
- 403
- 1
- 4
- 11
38
votes
1 answer
Django - Understanding X-Sendfile
I've been doing some research regarding file downloads with access control, using Django. My goal is to completely block access to a file, except when accessed by a specific user. I've read that when using Django, X-Sendfile is one of the methods of…

orokusaki
- 55,146
- 59
- 179
- 257
21
votes
2 answers
Using X-Sendfile with Apache/PHP
I can't seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code).
Anyone used it before and would mind giving a quick snippet of code and a brief description?
Patrick
17
votes
3 answers
Rails + X-Sendfile serving large video to Ipad
I have an application serving large (some hundreds of MB) video files and it is working perfectly on desktop browsers, using Rails + X-Sendfile on Apache.
An important requirement is that these videos must be private and visible only to logged…

sissy
- 2,908
- 2
- 28
- 54
11
votes
1 answer
Serving Large Files Through Nginx via Rails 2.3 Using x-sendfile
Let's say I have a Rails 2.3.2 application fronted by nginx and served by mongrel in which I need to serve a large static file through Rails (to control access to it). I want the Rails app to delegate the transfer of the file to nginx, to avoid…

Rich Apodaca
- 28,316
- 16
- 103
- 129
11
votes
4 answers
rails media file stream accept byte range request through send_data or send_file method
I have the following problem. Sounds are hidden from the public folder, cause there are only certain Users who should have access to the sound files. So I made a certain method, which acts like a sound url, but calculates first, whether the current…

Markus
- 3,948
- 8
- 48
- 64
11
votes
2 answers
iOS 10 won't send session ID when trying to deliver mp4 via X-Sendfile
I have a PHP file who's sole job is to check if a user is logged in + if a session variable is set, then delivers a file via nginx X-Sendfile. It works perfectly on any desktop browser, and previously on any mobile browser - but fails on any ios 10…

UltrasoundJelly
- 1,845
- 2
- 18
- 32
9
votes
3 answers
Message "X-Accel-Mapping header missing" in Nginx error log
I am running a Rails 3 site on Ubuntu 8.04 with Nginx 1.0.0 and Passenger 3.0.7.
In my Nginx error.log I started seeing the message X-Accel-Mapping header missing quite a lot. Googling lead me to the docs of Rack::Sendfile and to the Nginx…

Manuel Meurer
- 3,238
- 6
- 35
- 50
8
votes
3 answers
Test if X-Sendfile header is working
I am looking for a way to confirm if X-Sendfile is properly handling requests handed back to the webserver by a script (PHP). Images are being served correctly but I thought I would see the header in curl requests.
$ curl -I…

dalethedeveloper
- 165
- 2
- 7
8
votes
4 answers
rails - x-sendfile + temporary files
Some time ago I wrote a question regarding the use of temporary files within a rails app. On thar particular case, I decided to use tempfile
This causes a problem if I also want to use the x-sendfile directive (as a parameter in Rails 2, or as a…

kikito
- 51,734
- 32
- 149
- 189
8
votes
4 answers
Caching images in browser with URL parameters and XSendFile
I am trying to set up a site so that users only have access to their own images and audio files. To to this I am using variables in the URL such as:
On the front-end I am using React JS…


kojow7
- 10,308
- 17
- 80
- 135
8
votes
1 answer
fatal error: 'apr.h' file not found when installing x-sendfile mac os x mountain lion server
When I upgraded my Lion Server to Mountain Lion, it seems that it removed my mod_xsendfile from apache.
I followed the instructions from this web site, but got stuck with a "No such file or directory" error.
With some help from google i found this…

einord
- 2,278
- 2
- 20
- 26
7
votes
1 answer
mod_xsendfile with symbolic links
I'm running into an issue using xsendfile with my Rails 3 app.
I'm using capistrano to manage deployments and in each release, there is a symbolic link to the shared/assets dir (e.g. /var/www/site/releases/1234/assets =>…

bostonou
- 1,194
- 10
- 21
7
votes
2 answers
XsendFile with apache and django
I have my django served by apache using Vhost. The conf file is the following
WSGIPythonPath /srv/www/myproject/testproject/
ServerAdmin admin@betarhombus.com
ServerName www.betarhombus.com
WSGIScriptAlias /…

Apostolos
- 7,763
- 17
- 80
- 150