-
Notifications
You must be signed in to change notification settings - Fork 9
[FEATURE REQUEST] Support X-Sendfile Header #9
Comments
Hey @alexander-schranz. Thanks for the proposal. Could you please provide a little bit more details about how this feature works in Nginx, Apache, or Symfony? Might be some documentation. Thanks 👍🏻 |
@rustatian The response from PHP looks like the following in HTTP: HTTP/1.1 200 OK
x-sendfile: /var/data/website/private-directory/file.mp4
Content-Length: 12345 The The webservers looks for the There is also some docs here:
In symfony the
|
Great, thanks @alexander-schranz. I hope I'll implement it after the transition of the |
Valery, this work is pretty much connected with the custom response handlers we spoke about (streaming), since we will use a similar approach with the header. So it will require some HTTP layer refactoring first. But it will open a TON of interesting possibilities:
Also, it is connected to one of the distribution methods of https://github.com/spiral/distribution |
Feature accepted for the |
@alexander-schranz Feature will be available for testing by the end of the week in the |
## Description of Changes - Add support for the access logs at `Info` log level. Fields: `method` - http method. `remote_addr` - request remote address. `bytes_sent` - content-length, `http_host` - host. `request` - request Query. `time_local` - local time in Common Log Format. `request_length` - request body with headers size (content-len + size of all headers) in bytes. Max allowed headers size for the RR is 1MB. `request_time` - request processing time in seconds with a milliseconds resolution. `status` - http response status. `http_user_agent` - http user [agent](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) `http_referer` - http [referer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer) - ✏️ Access logs turned off by default, to turn on, please, use the following field in the configuration: ```yaml http: address: 127.0.0.1:58332 max_request_size: 1024 access_logs: true <----------------- NEW middleware: [ ] pool: num_workers: 2 max_jobs: 0 allocate_timeout: 60s destroy_timeout: 60s ``` - ✏️ HTTP middleware to handle Symfony's `X-Sendfile` [header](#9). ```yaml http: address: 127.0.0.1:44444 max_request_size: 1024 middleware: ["sendfile"] <----- NEW MIDDLEWARE pool: num_workers: 2 max_jobs: 0 allocate_timeout: 60s destroy_timeout: 60s ```
Awesome thank you all 👍 |
@alexander-schranz Please, test the |
Is your feature request related to a problem? Please describe.
When having private files behind a PHP firewall you return them in Symfony as a BinaryFileResponse. When supported by the Webserver in this case the
x-sendfile
header will be used which just tell the webserver where the file can be found which need to be streamed out.Describe the solution you'd like
It would be great when roadrunner would also support the x-sendfile header. I could not yet find a reference or a config how this kind of response are handled in roadrunner.
Describe alternatives you've considered
Alternative is not supporting
x-sendfile
Symfony does then fallback to a normal file stream to php://output.Additional context
Apache does support x-sendfile of the sendfile mod. Nginx I think does support it out of the box. The state of caddy webserver I don't know.
The text was updated successfully, but these errors were encountered: