frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Enable x-accel-redirect

Open withinboredom opened this issue 2 years ago • 3 comments

closes #365

This adds x-accel-redirect and friends by passing a "filter" to Frankenphp from Caddy. This "filter" allows us to halt output if we have a rewriting matcher that should take over the request. For backward compatibility, context strings are kept as http.reverse_proxy.*.

This is a refactoring of the reverse proxy functionality built into Caddy but adapted for FrankenPHP.

        php_server {
            @accel header X-Accel-Redirect *
            handle_response @accel {
              root * /
              rewrite {http.reverse_proxy.header.X-Accel-Redirect}
              file_server
            }
        }

Todo:

  • [x] worker support
  • [x] tests
  • [x] clean up debug log lines
  • [x] return docker files to a pristine condition
  • [x] refactoring
  • [x] documentation (for caddyfile)
  • [x] documentation (for frankenphp -- hooks)

Thoughts:

  • Anything other than handle_response is probably out of scope for this PR.

withinboredom avatar Dec 17 '23 00:12 withinboredom

Hey @withinboredom, do you mind if I push in your branch to finish this feature?

dunglas avatar Feb 26 '24 09:02 dunglas

Yeah, go for it. I just haven't had much time to get to this.

withinboredom avatar Feb 26 '24 11:02 withinboredom

Here is my alternative PR (directly in Caddy): https://github.com/caddyserver/caddy/pull/6232

dunglas avatar Apr 10 '24 12:04 dunglas

Closing in favor of https://github.com/caddyserver/caddy/pull/6232 that is likely to be merged. Thanks for paving the way @withinboredom!!

dunglas avatar Apr 23 '24 10:04 dunglas

🥳

withinboredom avatar Apr 23 '24 10:04 withinboredom