Nexus behind KONG repo

I’m trying to run nexus3 oss behind a kong repo. This is a trivial task for nearly everything else, but nexus (or maybe jetty) has made it complex.

My sonatype instance runs in kubernetes / nodeport using 8443 (https) endpoint. My kong instance runs on the same server (NOT in kubernetes) and I am using ‘path routing’ so that I can access the repository at https://hostname/nexus/ . Kong routes to (e.g. https://127.0.0.1:30111 which kubernetes routes internally to the sonatype instance).

This all works well for the index page. However apparently sonatype is able to detect the original ip / hostname, and appends its internal port number 8443. So when I “view-source” of the index page I see this:

<html lang="en">
<head>
  <title>Nexus Repository Manager</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="description" content="Nexus Repository Manager"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

  <!--[if lt IE 9]>
    <script>(new Image).src="https://172.16.1.1:8443/static/rapture/resources/favicon.ico?_v=3.28.1-01&_e=OSS"</script>
  <![endif]-->

Note also that the /nexus/ path is stripped.

How can I use kong and nexus together using path (not hostname) routing?

I’ve been struggling with this for at least a month. If I was using just nginx it would be simple, but I
have to use kong for this.

Thanks for your attention.

Never heard of kong but there is documentation for running behind a reverse proxy, you’ll need to translate the instructions yourself - Run Behind a Reverse Proxy

I tried to proxy nexus with Kong and encountered the similar issue.

I found the earlier nexus versions (such as sonatype/nexus3:3.20.1) used baseUrl (seems absolute path) in static pages and the latest version(3.37.2-02) has changed to use relativePath for them. So I can proxy the latest version. But I also want to know how to proxy the old versions.

I believe you can add a base path to the urls on older versions, then proxy to that base url for things to work correctly. Just enable the Base URL Capability