Prev: Next: Up: Backends[Contents][Index]


10.11.4.3 Special Backends

Special backends are backends that don’t rely on an external server to handle the response, but instead are served by pound itself.

Service directive: Control

Defines a special backend that serves pound management interface. See Remote Access to Management Interface, for a detailed discussion of this feature.

Service directive: Emergency ... End

Defines an emergency backend, which will be used only if all other backends become unavailable. See Backend, for a discussion of directives that can be used within Emergency section.

If multiple Emergency sections are defined, an emergency backend to use will be selected using the usual balancing technique (see Request balancing).

Service directive: Error status [file]

Return a particular HTTP status.

The status argument supplies the HTTP status code to return.

Optional file argument is the name of a disk file with the error page content. If not supplied, the text is determined as usual: first the ErrorFile status statement from the enclosing listener is consulted. If it is not present, the default error page is used.

This directive is useful in a catch-all service, which outputs an error page if no service matching the incoming request was found. See Error responses, for a discussion.

Service directive: LuaBackend "func" ["arg"...]

Run Lua function func with the supplied arguments. The function should set the response code (see http.resp.code) and fill the response body (see http.resp.body) prior to returning. If it fails to do so, pound will generate a standard 500 response.

The func can be either an unqualified function name, or function name with module qualifier (module.func).

Each arg is subject to to backreference expansion and request accessor interpretation, as discussed in Request modifications.

This statement is available only if pound was built with Lua support. See Lua backends, for a detailed discussion.

Service directive: Metrics

This directive defines a special backend that generates Openmetric telemetry output on the given URL. Example usage:

Service
    URL "/metrics"
    Metrics
End

To control access to the telemetry endpoint, use the ACL statement (see ACL).

The LogSuppress directive (see LogSuppress) is often used in openmetric services to suppress logging of served HTTP requests:

Service
    URL "/metrics"
    Metrics
    ACL "secure"
    LogSuppress success
End

The metrics output is discussed in Metric Families.

Service directive: Redirect [code] "url"

Declares a special backend that responds to each request with a redirect response.

Optional code can be one of: 301, 302 (the default), 303, 307, or 308.

The url argument specifies the URL to redirect the request to. Before use it is expanded as described in String Expansions.

For compatibility with previous pound versions, if no ‘$n’ references are found in url, the following logic is used: if it is a "pure" host (i.e. with no path) then the client will be redirected to that host, with the original request path appended. If the url does contain a path (even if it is just a ‘/’), then the request path is ignored.

See Redirects, for a detailed discussion of this backend and its use.

Service directive: SendFile dir

Defines a special backend that serves static files from directory dir. Name of the file to serve is supplied by the request path, after applying usual request modifications (see Request Modification). By default, the response bears Content-Type: text/plain header. To change this, use SetHeader statement in response rewriting (see The Rewrite response statement.).

The following example defines a service which will serve requests to paths beginning with ‘/about/’ from directory /var/lib/pound/static. Name of the file to serve is obtained by removing the ‘/about/’ prefix from the request pathname. Content type is set to ‘text/html’:

Service
    Path -re "/about/(.+)"
    SetPath "$1"
    Rewrite response
         SetHeader "Content-Type: text/html"
    End
    SendFile "/var/lib/pound/static"
End

If dir is not an absolute file name, it is resolved relative to pound include directory (see include directory).

Service directive: Success

A Success backend always returns 200 response code. It can be used for debugging or for side effects, e.g. to answer OPTIONS requests by supplying response headers using SetHeader.

Service
    Method "OPTIONS"
    Rewrite response
        SetHeader "Access-Control-Allow-Origin: example.com"
        SetHeader "Access-Control-Allow-Methods: GET,POST,PUT"
        SetHeader "Access-Control-Max-Age: 1800"
    End
    Success
End

Prev: Next: Up: Backends[Contents][Index]