Using JupyterLab with subfolder reverse proxy

I’m trying to use JupyterLab with a subfolder reverse proxy such that I can access it at domain.tld/jupyter. This works, but Jupyter seems to use a lot of redirects and doesn’t know about the subfolder, so it tries to login and goes to domain.tld/login instead of domain.tld/jupyter/login. I tried to fix this by setting base_url to /jupyter/, but now it’s listening for /jupyter and the reverse proxy does not pass this on. So to login you have to go to domain.tld/jupyter/jupyter/login. Is there a way to setup JupyterLab to use a path for its links and redirects without listening on it?

It sounds like you need to configure your proxy to correctly pass (or not pass, depending on how your proxy works) the path. For example in Nginx:

I was able to make it work by setting --ServerApp.base_url /jupyter/ and changing rewrite /jupyter(.*) $1 break; to (.*) $1 break;