Pleroma v1.1.9-10-g42f76306+dev Pleroma.ReverseProxy View Source

A reverse proxy., url, options)

It is not meant to be added into a plug pipeline, but to be called from another plug or controller.

Supports ["GET", "HEAD"] HTTP methods, and only allows [200, 206, 304] status codes.

Responses are chunked to the client while downloading from the upstream.

Some request / responses headers are preserved:

  • request: ["accept", "user-agent", "accept-encoding", "cache-control", "if-modified-since", "if-unmodified-since", "if-none-match", "if-range", "range"]
  • response: ["etag", "date", "last-modified", "cache-control", "content-type", "content-disposition", "content-encoding", "content-range", "accept-ranges", "vary"]

If no caching headers (["etag", "date", "last-modified", "cache-control"]) are returned by upstream, cache-control will be set to "public, max-age=1209600".


  • redirect_on_failure (default false). Redirects the client to the real remote URL if there's any HTTP errors. Any error during body processing will not be redirected as the response is chunked. This may expose remote URL, clients IPs, ….

  • max_body_length (default :infinity): limits the content length to be approximately the specified length. It is validated with the content-length header and also verified when proxying.

  • max_read_duration (default 30000 ms): the total time the connection is allowed to read from the remote upstream.

  • failed_request_ttl (default 60000 ms): the time the failed request is cached and cannot be retried.

  • inline_content_types:

    • true will not alter content-disposition (up to the upstream),

    • false will add content-disposition: attachment to any request,

    • a list of whitelisted content types

    • keep_user_agent will forward the client's user-agent to the upstream. This may be useful if the upstream is doing content transformation (encoding, …) depending on the request.

  • req_headers, resp_headers additional headers.

  • http: options for hackney.

Link to this section Summary

Link to this section Types

Link to this type


View Source
option() ::
  {:keep_user_agent, boolean()}
  | {:max_read_duration, :timer.time() | :infinity}
  | {:max_body_length, non_neg_integer() | :infinity}
  | {:failed_request_ttl, :timer.time() | :infinity}
  | {:http, []}
  | {:req_headers, [{String.t(), String.t()}]}
  | {:resp_headers, [{String.t(), String.t()}]}
  | {:inline_content_types, boolean() | [String.t()]}
  | {:redirect_on_failure, boolean()}

Link to this section Functions

Link to this function

call(conn, url, opts \\ [])

View Source
call(Plug.Conn.t(), url :: String.t(), [option()]) :: Plug.Conn.t()