Access to custom app via /hub/user-redirect/proxy/{port} | k8s | jupyterhub

Context

I have a k8s cluster with jupyterhub inspired by “Zero to JupyterHub with Kubernetes”.

I’ve ran a simple flask code (in jupyter notebook/user’s pod). Let say the server listening on port - 8050 and i want to get access to output via url.

I tried in this way: /hub/user-redirect/proxy/8050.
After authentication, it was redirect here: /user/vladimir/proxy/8050

Error

# 404 : Not Found
You are requesting a page that does not exist!

I’ve logged to jupyter-user pod via kubectl and i use curl to double-check. The server works properly.

$ curl localhost:8050
Hello, World!

Here is a simple flask code.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'


if __name__ == '__main__':
      app.run(host='0.0.0.0', port=8050)

Question

What i should change in my configuration to see “hello world” (the output from my flask) in the browser via url?

P.S. the similar things is needed also for mlflow etc.

/proxy/:port isn’t handled by the Jupyter server by default. This feature is provided by an extension called jupyter server proxy. You’ll need to install and enable that extension in the user environment, at which point it should work.

thanks @minrk :+1: it works now