Jupyter-server-proxy and Tomcat

I got Tomcat working partially with jupyter-server-proxy. I have:

c.ServerProxy.servers = {
   'Tomcat': {
    'command': ['/opt/tomcat/latest/bin/startup.sh'],
    'timeout': 30,
    'port': 8080,
    'absolute_url': False,
    'launcher_entry': {
            'title': 'Tomcat'
    }
  }
}

And Tomcat loads fine from the new menu, and once in the main tomcat page where I can see the list of deployed war files, the links for accessing each app (war files) are fine (with the /user/{username}/Tomcat/{appname} prefix path after the domain name) but once clicking on it, it makes a 302 redirection to /hub/{appname} so I get a 404 not found.

Does anybody know why this 302 redirect happens and how to solve it?

I found out it is a 302 in the pod logs.
Thank you

My guess is that your Tomcat app is not detecting it’s base/prefix URL correctly. If it’s using relative links they should work, but if it needs the full path this is where things can go wrong.

Config options you could try modifying include:

Thank you for your answer.
The fact is that the Tomcat startup script does not have any parameter to state the base url.

I want to clarify that the situation I explained before happens when I start Tomcat from within vscode (code-server), and accessing Tomcat in a full tab browser from the new menu in the single-user jupyter classic main page (i.e. using jupyter-proxy-server), meaning Tomcat is already started (it is not started by the command in the config trailet mentioned above).

Inside vscode, the links for any deployed app found in the main Tomcat webpage are working fine and the 302 redirect is not happening.

On the other hand, if Tomcat is not started from vscode, but using jupyter-server-proxy (i.e. starting Tomcat with the script stated in the config trailet) Tomcat starts well, but the Tomcat welcoming page then has all links relative, and clicking on them this adds only the domain name, omitting the suffix /user/{username}/Tomcat which lead me to all 404 not found errors. If I manually add this path suffix to the url I get in the links, then it works.

My question would be how can I make all links in Tomcat welcoming page to include the path /user/{username}/Tomcat (all links are relative, but clicking on them I get {domain}/hub/whatever_relative_name_the_link_has).

I also tried with absolute_url = True in the trailet, but then not even the Tomcat main page loads.

If anyone can provide some help, it would be really appreciated.

Maybe a Tomcat expert could also provide some clues on how to config Tomcat to be aware of a different base_url, as I said above, this is not an option you can state in the startup script.

Thank you again

1 Like

This where some optional path prefix headers are set:

Hopefully a Tomcat expert will be able to say whether Tomcat apps can be configured to use them or whether the base_url needs to be set some other way :slight_smile: