Custom base URL

Configure UI Bakery for a custom base URL

Docker Compose and standalone NGINX

If you have set up your instance using Docker Compose, the easiest way to run UI Bakery under a base URL is to configure an NGINX server as a reverse proxy for your instance. The example below demonstrates how to run UI Bakery at http://example.com/bakery 1. Install NGINX

sudo apt update
sudo apt install nginx

2. Create an NGINX configuration file

Create an NGINX configuration file at /etc/nginx/sites-enabled/example.com with the following content:

server {
  listen 80;
  listen [::]:80;
  server_name example.com;
  client_max_body_size 50M;
  
    location /bakery {
      rewrite /bakery/(.+) /$1 break;
      proxy_pass http://localhost:3030;
    }
}

3. Update environment variables

Update the following UI Bakery environment variables:

UI_BAKERY_APP_SERVER_NAME=http://example.com/bakery
UI_BAKERY_BASE_PATH=/bakery/
UI_BAKERY_WORKBENCH_URL=/bakery/workbench/
UI_BAKERY_WORKBENCH_BASE_PATH=/bakery/workbench/

4. Restart UI Bakery and NGINX

After updating the configuration and environment variables, restart NGINX and UI Bakery:

# restart nginx
sudo systemctl reload nginx
# restart ui bakery
docker compose up -d

Kubernetes

If you're already running UI Bakery on Kubernetes and want to relocate it under a specific path, such as /bakery, follow these steps:

1. Modify gateway configuration file

Update your ui-bakery-gateway.yaml file. Change the spec type from LoadBalancer to ClusterIP

2. Add ingress-nginx

Install ingress-nginx using Helm:

helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ui-bakery

3. Create UI Bakery ingress configuration

Create a ui-bakery-ingress.yaml configuration file with the following content:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ui-bakery-ingress
  namespace: ui-bakery
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite /bakery/(.+) /$1 break;
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /bakery
        pathType: ImplementationSpecific
        backend:
          service:
            name: bakery-gateway
            port:
              number: 3030

4. Update UI Bakery config

Adjust the following UI Bakery environment variables:

UI_BAKERY_APP_SERVER_NAME: https://example.com/bakery
UI_BAKERY_BASE_PATH: /bakery/
UI_BAKERY_WORKBENCH_URL: /bakery/workbench/
UI_BAKERY_WORKBENCH_BASE_PATH: /bakery/workbench/

5. Restart your instance

Apply changes with:

kubectl apply -f .
# you may need to restart frontend
kubectl rollout restart deployment/ui-bakery-front --namespace=ui-bakery
kubectl rollout restart deployment/ui-bakery-workbench-front --namespace=ui-bakery

Last updated