Nexus NuGet v3 repo behind reverse proxy

Hey there. I have Nexus OSS 3.25-1.04 behind Nginx reverse proxy. I’ve created NuGet repository. It’s OK by using external and internal URL. But when I try to use it as NuGet v3 repo I see only internal URLs inside index.json file. I open it via https://external_url/repository/nuget_repo/index.json. BTW whatever URL is used in the very first request to a repo after Nexus service startup is embedded into index.json .
Is it a normal behavior or is there any additional settings for this case?
Thanks

1 Like

@slaffka.vlasov If I understand your question correctly then this sounds like normal behaviour. If NXRM return external URLs then your Nuget client would circumvent the repository manager and go direct to the remote. NXRM replaces the URLs so that all requests go through it and packages get cached correctly.

so does it mean that the very first request to the repo after service restart “fulfills” index.json with URLs depends on the request? I mean that if you enter internal URL you will see only internal URLs inside index.json

Correct. It should be possible to fix that URL to a specific value using the Base URL capability if you need: Base URL Capability

aah I saw these KB thanks. But I’ve thought that it can rewrite URLs only in email notifications.

and I’ve just tried to create a new NuGet repo and access it via IP address. Now I see only IP addresses inside index.json

Let me clarify original request regarding reverse-proxy, expected and actual behavior.

Nexus instance is running behind reverse-proxy. As a result it can be accessed with http://external_url and http://internal_url.
The instance hosts nuget hosted repository, which we want to be available over nuget api version 3.
Version 3 of the protocol assumes that nuget feed shall be added using /repository/nuget-hosted/index.json URL.

Given external and internal URLs, nuget feeds look like:
http://external_url/repository/nuget-hosted/index.json
http://internal_url/repository/nuget-hosted/index.json

Expected behavior is that index.json is referencing endpoints using whatever URL was used to access it: when external URL is used, index.json shall reference everything starting from http://external_url and when internal URL is used, index.json shall reference everything starting from http://internal_url

However, on practice we see that the very first request to nuget repository after Nexus service startup seem to make Nexus “remember” URL and embed it into index.json regardless whether it is accesses over internal or external URL. For instance, if first request is made using http://internal_url/repository/nuget-hosted/index.json, then for all subsequent requests Nexus will reference everything in index.json starting from http://internal_url. Even if subsequent requests are made over http://external_url. Even from different browsers. Even from different PC.

Base URL Capability has no effect on this behavior. The only factor we are currently seeing that has effect is which URL was used to make first request to index.json after Nexus service has started.

So, the question is. Should it really behave this way?

@adm.malax That is because the index.json metadata is cached for performance optimization. If you set Max metadata age to 0 does it then get regenerated on each request? If not you will have to file an Improvement request at https://issues.sonatype.org

@jstephens Your explanation seems very likely.
I can’t find any documentation where Max Metadata age can be set. The only article I found is Understanding Caching Configuration – Sonatype Support, but judging by the text, this is only applicable to proxy repositories. Which is not our case. We are using hosted repository.
Could you please point me towards where Max Metadata age you were talking about can be set? Or where I can read about it?

Ah didn’t realize this was hosted / group. You will need to file an improvement ticket to make the caching of that file configurable.

1 Like

Thanks…
I’ve raised the ticket https://issues.sonatype.org/browse/NEXUS-25733 about these issue. Maybe there is a way to fix it :slight_smile:

1 Like

Hi Slava,
Have you found a solution? Unfortunately, SonaType replaced the Jira issue tracker with Zendesk and I cannot see the contents (or a solution) anymore. I think we have a similar issue with one of the nuget packages, and I’m unable to fix it.
Thanks,
Mariska

I confirmed NEXUS-25733 is marked as fixed. If you’re still having problems and using a reverse proxy in front of Nexus please ensure it is configured to propagate headers correctly - Run Behind a Reverse Proxy

We have the reverse proxy configured correctly and most nuget packages can be downloaded without a problem.

We have a hosted nuget repository in our nxrm3 instance that is accessed via a reverse proxy.

In short:

https://nexus-external-urlhttp://nexus-internal-url

The nexus-internal-url is not accessible directly, only from the reverse proxy.

For unknown reason, there is one nuget package (all package versions are affected) that shows the internal url in the package id instead of the external url. I can see that in the https://nexus-external-url/repository/nuget-hosted/v3/registration/5/package-x/index.json. Note that for most packages the id does point to the external nexus url. It just seems to be a problem with one package.

When teams try to download this package via ‘nuget install’, they get an error message:


PS C:\> nuget install PackageX -version 2.24.0 -source https://nexus-external-url/repository/nuget-hosted/index.json
Feeds used:
https://nexus-external-url/repository/nuget-hosted/index.json

Attempting to gather dependency information for package 'PackageX.2.24.0' with respect to project 'C:\', targeting 'Any,Version=v0.0'
Gathering dependency information took 423 ms
Attempting to resolve dependencies for package 'PackageX.2.24.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'PackageX.2.24.0'
Resolved actions to install package 'PackageX.2.24.0'
Retrieving package 'PackageX 2.24.0' from 'https://nexus-external-url/repository/nuget-hosted/index.json'.

GET http://nexus-internal-url/repository/nuget-hosted/v3/content/PackageX/2.24.0/PackageX.2.24.0.nupkg
BadGateway http://nexus-internal-url/repository/nuget-hosted/v3/content/PackageX/2.24.0/packagex.2.24.0.nupkg 3069ms
WARNING: Error downloading 'PackageX.2.24.0' from 'http://nexus-internal-url/repository/nuget-hosted/v3/content/packagex/2.24.0/packagex.2.24.0.nupkg'.
Response status code does not indicate success: 502 (Bad Gateway).

The https://nexus-external-url/repository/nuget-hosted/v3/registration/5/packagex/index.json registry shows:


"count":1,"items":[{"count":12,"lower":"2.17.0","upper":"2.25.0-alpha0013","parent":"http://nexus-internal-url/repository/nuget-hosted/v3/registration/packagex/index.json","@id":"http://nexus-internal-url/repository/nuget-hosted/v3/registration/packagex/index.json#page/2.17.0/2.25.0-alpha0013","items":[.....]

I’ve tried rebuilding the index, but the index.json hasn’t changed. It also doesn’t seem right that those package id’s are hardcoded in the index.

So, the big question: Does anyone know how to fix this: recreate the index.json from scratch ?

Any help is greatly appreciated!

Note: we are running Nexus OSS 3.66.0-02.

Kind regards,

Mariska.