Repository: provectus/kafka-ui
Issue: Routing to KafkaUI using Traefik.
Labels: type/enhancement

### Is your proposal related to a problem?

Is it possible to make this as clear as the San Diego summer sky:

SERVER_SERVLET_CONTEXT_PATH | URI basePath

It's not clear what this is for. 

I assume it's so that I can run this as a service on a path `localhost/kafkaui`?

I am using this with traefik and routing to the UI using prefix `/kafkaui` but I get an error

this is the output in the console.
`
kafkaui_1     | 12:19:16.903 [boundedElastic-2] DEBUG org.springframework.http.codec.json.Jackson2JsonEncoder - [f0610232] Encoding [class ErrorResponse {
kafkaui_1     |     code: 5000
kafkaui_1     |     message: 404 NOT_FOUND
kafkaui_1     |     timestamp: 1624364356903
kafkaui_1     |     req (truncated)...]
`
this is the output in the browser

`
{"code":5000,"message":"404 NOT_FOUND","timestamp":1624364356903,"requestId":"f0610232","fieldsErrors":null}
`

this is my docker-compose

`
version: "3.8"

services:

  kafkaui:
    image: provectuslabs/kafka-ui:latest
    environment:
      - KAFKA_CLUSTERS_0_NAME=local
      - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092
      - KAFKA_CLUSTERS_0_ZOOKEEPER=zookeper:2181
      - SERVER_SERVLET_CONTEXT_PATH=kafkaui
    labels:
      # note that you want this frontened to match the last. otherwise it will match login.${HOST_DOMAIN}"
      traefik.frontend.priority: 1
      traefik.enable: true
      traefik.http.routers.kafkaui.rule: "PathPrefix(`/kafkaui`)"
      traefik.http.routers.kafkaui.entrypoints: web
      traefik.http.routers.kafkaui-https.rule: "PathPrefix(`/kafkaui`)"
      traefik.http.routers.kafkaui-https.tls: true
      traefik.http.routers.kafkaui-https.entrypoints: websecure
      traefik.http.services.kafkaui.loadbalancer.passHostHeader: true

    networks:
      - internal


networks:
  internal:
`

Issue comments:
Hi, @wildone. SERVER_SERVLET_CONTEXT_PATH could be used to set non root path for ui & api. Could you please share what were urls in your browser?
Hi, sorry for the late resolution, I hope that you solved your problem, we tested the application with traefik and it is working fine, at least all routings are correct. An example of usage could be found here https://github.com/provectus/kafka-ui/pull/763 

Pull request review comments:

Patch that resolved the issue:
diff --git a/docker/kafka-ui-traefik-proxy.yaml b/docker/kafka-ui-traefik-proxy.yaml
new file mode 100644
index 00000000000..e95d7a049b4
--- /dev/null
+++ b/docker/kafka-ui-traefik-proxy.yaml
@@ -0,0 +1,27 @@
+---
+version: '3.8'
+services:
+  traefik:
+    restart: always
+    image: traefik:v2.4
+    container_name: traefik
+    command:
+      - --api.insecure=true
+      - --providers.file.directory=/etc/traefik
+      - --providers.file.watch=true
+      - --entrypoints.web.address=:80
+      - --log.level=debug
+    ports:
+      - 80:80
+    volumes:
+      - ./traefik:/etc/traefik
+
+  kafka-ui:
+    container_name: kafka-ui
+    image: provectuslabs/kafka-ui:latest
+    ports:
+      - 8082:8080
+    environment:
+      KAFKA_CLUSTERS_0_NAME: local
+      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
+      SERVER_SERVLET_CONTEXT_PATH: /kafka-ui
diff --git a/docker/traefik/kafkaui.yaml b/docker/traefik/kafkaui.yaml
new file mode 100644
index 00000000000..3d0cf089d78
--- /dev/null
+++ b/docker/traefik/kafkaui.yaml
@@ -0,0 +1,11 @@
+http:
+  routers:
+    kafkaui:
+      rule: "PathPrefix(`/kafka-ui/`)"
+      entrypoints: web
+      service: kafkaui
+  services:
+    kafkaui:
+      loadBalancer:
+        servers:
+          - url: http://kafka-ui:8080
\ No newline at end of file


Test patch: