Skip to content

docs: X-Sendfile/X-Accel-Redirect#896

Merged
dunglas merged 3 commits intomainfrom
docs/x-sendfile
Apr 14, 2025
Merged

docs: X-Sendfile/X-Accel-Redirect#896
dunglas merged 3 commits intomainfrom
docs/x-sendfile

Conversation

@dunglas
Copy link
Copy Markdown
Member

@dunglas dunglas commented Jul 2, 2024

Closes #884.
Needs caddyserver/caddy#6429.

@Koc
Copy link
Copy Markdown

Koc commented Jul 27, 2024

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

@nicolas-grekas
Copy link
Copy Markdown
Contributor

nicolas-grekas commented Sep 5, 2024

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).

@withinboredom
Copy link
Copy Markdown
Member

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

@nicolas-grekas
Copy link
Copy Markdown
Contributor

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

@withinboredom
Copy link
Copy Markdown
Member

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

@dunglas
Copy link
Copy Markdown
Member Author

dunglas commented Jan 8, 2025

@nicolas-grekas it's not necessary because we change the root directory (see also dunglas/frankenphp-demo#28)

Copy link
Copy Markdown
Contributor

@aleho aleho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me with the latest Docker container.

I just noticed a few "problems" when using Symfony.

@dunglas
Copy link
Copy Markdown
Member Author

dunglas commented Jan 10, 2025

What problems did you have?

@aleho
Copy link
Copy Markdown
Contributor

aleho commented Jan 10, 2025

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
Copy link
Copy Markdown
Contributor

aleho commented Feb 27, 2025

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=

@dunglas dunglas force-pushed the docs/x-sendfile branch 3 times, most recently from 13ba626 to b03a0a6 Compare April 14, 2025 15:07
@dunglas dunglas merged commit 5e1ad5d into main Apr 14, 2025
56 checks passed
@dunglas dunglas deleted the docs/x-sendfile branch April 14, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"no such file or directory" with handle_response

5 participants