Serving jupyterhub on path other than root using nginx controller

Hello everyone,

I have two service which I want to serve on different paths using nginx ingress controller.

One of the services in Jupyterhub. I have tried multiple combinations of REGEX and rewrite paths but somehow I am not able to serve JHUB on any other path than “/” (root). I know I might be missing something very small here. Can anybody help me with this?

Here is my ingress.yaml file

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nb-ingress
  namespace: dev
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    - host: mydomain.net
      http:
        paths:
          - path: /jupyter(/|$)(.*)
            backend: 
              serviceName: proxy-public
              servicePort: 80

Thank you!!

You need to configure JupyterHub to run under a prefix by setting base_url
https://jupyterhub.readthedocs.io/en/stable/api/app.html#jupyterhub.app.JupyterHub.base_url

If you’re using the official Helm chart you can set it with hub.baseUrl

Thank you @manics. It worked fine :smile: