Skip to content

view ​

view serves a combined UI for Swagger definitions, gRPC services, iframes, and reverse-proxied pages.

yaml
server:
  http:
    middlewares:
      docs_view:
        view:
          prefix_path: /view/
          info_url_type: yaml
          info:
            swagger_settings:
              base_path_prefix: /api
              disable_authorize_button: true
              schemes: [HTTPS]
            swagger:
              - name: petstore
                link: https://petstore.swagger.io/v2/swagger.json
            page:
              - name: admin
                path: admin
                url: http://admin.internal:8080
                proxy: http://proxy.internal:3128
                rewrite:
                  base: true
                  absolute: true
                  origin: true
                  location: true
                  cookie: true
                  frame: true
                  forward_prefix: true
                  replace:
                    - old: https://another.internal
                      new: "{{prefix}}"
FieldDescription
prefix_pathBase path for the UI.
info_urlOptional URL that returns the Swagger list.
info_url_typeyaml or json when info_url is used.
insecure_skip_verifySkip TLS verification while fetching info_url.
info.swaggerList of Swagger documents.
info.swagger_settingsDefaults applied to Swagger documents.
info.pagePages reverse-proxied under {prefix_path}/page/{path}.

Use info_url when the list should come from another service; otherwise configure info inline.

Each page may set proxy to an HTTP proxy URL. Turna then sends that page's upstream HTTP and HTTPS requests through the configured proxy. Credentials may be included in the URL, for example http://user:pass@proxy.internal:3128.

Page rewriting ​

Page rewriting is opt-in. It adapts an application that expects to run at the root so it can run under the view page prefix.

FieldDescription
baseInject a <base> tag into HTML so relative references resolve under the page prefix.
absolutePrefix root-absolute HTML and CSS references such as /assets/app.js. Protocol-relative URLs are unchanged.
originReplace references to the configured backend origin with the page prefix, including JSON-escaped origins.
locationRewrite same-backend absolute and root-relative Location headers.
cookiePrefix Set-Cookie paths and remove backend Domain attributes.
frameRemove X-Frame-Options and only the CSP frame-ancestors directive.
forward_prefixSend the public page path in X-Forwarded-Prefix.
content_typesMedia types whose bodies may be rewritten. Defaults to HTML, XHTML, and CSS.
max_body_sizeMaximum response body buffered for rewriting, in bytes. Defaults to 10 MiB. Larger responses pass through unchanged.
replaceCustom literal or RE2 regular expression body replacements, applied after built-in rewriting.

Each replace entry accepts old or regex, new, and optional content_types. new supports and ; regular expression replacements also support $1 capture expansion.

When body rewriting is enabled, the proxy requests identity encoding from the backend. Gzip responses are also decoded safely when a backend ignores that request. Other content encodings pass through unchanged.