Skip to content

Support for nginx style X-Accel headers in reverse_proxy #3828

@segevfiner

Description

@segevfiner

Nginx has support for an upstream server to effect it by setting X-Accel-* headers in the response (NGINX | X-Accel).

This feature is very useful for various different scenarios, for example:

  1. Disabling buffering for certain requests without having to write specialized configuration in the proxy server for them. e.g. A route that returns large files (X-Accel-Buffering).
  2. Offloading protected/restricted static files to the proxy server, by an internal/named location only accessible ro such internal redirects (X-Accel-Redirect).
  3. Offloading certain requests to a different server proxied by Nginx. Often an internal/named location, only accessible by such internal redirects (X-Accel-Redirect).

Some of this behavior is probably possible by handle_response, which is not currently available in the Caddyfile (#3707), and even if it would be available, a stock handler/config snippet for this behavior would still be useful.

Note that there are some fine details with how nginx behaves with those headers, for example: It changes the request method to a GET unless you redirect to a named location when using X-Accel-Redirect. Both changing the method (e.g. A POST that redirects to a static file), and not changing it (e.g. Offload to a different proxied server) are useful and need consideration how to make them available in caddy.

It also doesn't seem like Caddy has such named locations or internal locations/matcher to create such internal redirect only routes.

Also another interesting custom header of this sort is X-Sendfile supported by Apache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions