frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

docs: X-Sendfile/X-Accel-Redirect

Open dunglas opened this issue 1 year ago • 5 comments

Closes #884. Needs https://github.com/caddyserver/caddy/pull/6429.

dunglas avatar Jul 02 '24 21:07 dunglas

how to deal with that if we're storing files in AWS S3-like storages?

Koc avatar Jul 27 '24 22:07 Koc

It looks like this is missing sending the X-Accel-Mapping header that Symfony needs to generate the correct redirect. See https://mattbrictson.com/blog/accelerated-rails-downloads for how this works on RoR (Symfony behaves the same).

nicolas-grekas avatar Sep 05 '24 09:09 nicolas-grekas

@nicolas-grekas If I am understanding correctly, this is a header sent from the webserver to PHP?

withinboredom avatar Sep 05 '24 10:09 withinboredom

@withinboredom correct, to advertise the mapping between URL prefix and internal path.

nicolas-grekas avatar Sep 05 '24 10:09 nicolas-grekas

I think this is doable, just needs to be documented. I'll take a look later today.

withinboredom avatar Sep 05 '24 10:09 withinboredom

@nicolas-grekas it's not necessary because we change the root directory (see also https://github.com/dunglas/frankenphp-demo/pull/28)

dunglas avatar Jan 08 '25 22:01 dunglas

What problems did you have?

dunglas avatar Jan 10 '25 13:01 dunglas

What problems did you have?

Only my comments on the review. And one of them turned out to be wrong assumptions on my end anyway.

aleho avatar Jan 10 '25 14:01 aleho

With this simple config:

request_header X-Sendfile-Type x-accel-redirect
request_header X-Accel-Mapping /private-files=

intercept {
	@accel header X-Accel-Redirect *
	handle_response @accel {
		root    * /private-files
		rewrite * {resp.header.X-Accel-Redirect}
		method  * GET

		header -X-Accel-Redirect
		header -X-Accel-Buffering

		file_server
	}
}

php_server

Each response produces this error output: ERROR frankenphp the current responseWriter is not a flusher {"error": "feature not supported"}

Can anyone confirm / reproduce that?

FrankenPHP: v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

aleho avatar Feb 27 '25 08:02 aleho