HTTP Path Rewrites
If you want to host Redpanda Console under a subpath rather than the root path, you need to configure HTTP path rewrites. This allows you to serve Redpanda Console under a subpath of your domain, such as https://my-company.com/redpanda/console
, instead of directly from https://my-company.com
. This type of configuration is often necessary when:
-
You have multiple services and applications running under the same domain.
-
Redpanda Console is behind a reverse proxy. The proxy might add a path prefix based on routing rules, and Redpanda Console needs to know about this prefix to handle requests correctly.
If you host Redpanda Console at a root path, for example under a sub-domain such as https://console.redpanda.my-company.com , you don’t need to configure HTTP path rewrites.
|
Configuration
To configure HTTP path rewrites, set the following properties within the server
object in your Redpanda Console configuration file:
Configuration | Description | Default |
---|---|---|
|
The subpath under which Redpanda Console is hosted. If you have a proxy in front of Redpanda Console that sets the |
|
|
Tells Redpanda Console to use the If this header is present, its value will be used as the path prefix, and the value set in |
|
|
Removes the specified prefix from the request path before routing it to Redpanda Console. If your proxy is configured to remove the prefix, you should disable |
|
Custom subpath scenario
Consider the following setup where you want to host Redpanda Console at https://my-company.com/redpanda/console/
and are using a reverse proxy to manage the routing:
-
Nginx is configured to route requests from
/redpanda/console
to Redpanda Console, running onhttp://localhost:8080
.Redpanda Console configurationserver: setBasePathFromXForwardedPrefix: true stripPrefix: true
yamlNginx configurationlocation /redpanda/console/ { proxy_pass http://localhost:8080/; proxy_set_header X-Forwarded-Prefix /redpanda/console; }
nginx -
A user navigates to
https://my-company.com/redpanda/console/topics
in their browser. -
Nginx receives the request and recognizes the
/redpanda/console
subpath. It forwards the request to Redpanda Console athttp://localhost:8080/topics
, while adding theX-Forwarded-Prefix: /redpanda/console
header. -
Because
setBasePathFromXForwardedPrefix
is set totrue
, Redpanda Console checks theX-Forwarded-Prefix
header. It identifies that the base path is/redpanda/console
and removes this prefix from the incoming request path. The request path/topics
is now correctly routed in Redpanda Console.
If Nginx were configured without the X-Forwarded-Prefix
header, or if setBasePathFromXForwardedPrefix
was set to false
, Redpanda Console would not correctly recognize the subpath, leading to routing issues.
This configuration is particularly useful when multiple environments or proxies might route to the same Redpanda Console instance under different subpaths.
Prefix removal scenario
Some proxies, such as Traefik, can remove a prefix from the URL path before forwarding it. If both the proxy and Redpanda Console attempt to remove the prefix, Redpanda Console may fail to route the request correctly. Only one part of the stack (either the proxy or Redpanda Console) should remove the prefix.
To better understand this problem, consider the following scenario:
-
Traefik is configured to route
/topics
to Redpanda Console with the "StripPrefix" middleware enabled. -
Redpanda Console is configured with the default settings, which includes
stripPrefix: true
. -
A user enters the following address in their browser:
example.com/topics/topics/example-topic
. -
Traefik removes the first
/topics
from the path, leaving/topics/example-topic
, and sets/topics
in theX-Forwarded-Prefix
header. -
Redpanda Console sees the
X-Forwarded-Prefix
and attempts to remove what it thinks is the prefix. The path becomes/example-topic
. -
Redpanda Console then tries to find a handler for
/example-topic
, but no such route exists, leading to a failure.
To avoid this issue, either disable stripPrefix
in Console or ensure that the proxy does not modify the request path in a conflicting manner.
Proxy rewrites
If you have a reverse proxy between Redpanda Console and Kafka Connect, ensure that any rewrite rules retain the necessary expand parameters in the query string. These parameters are crucial for Kafka Connect to return the correct details about the connectors:
://<kafka_connect_host>:8083/connectors?expand=info&expand=status
This ensures that Redpanda Console can correctly communicate with Kafka Connect even when hosted behind a proxy that rewrites URLs.