How does Automatic Routing work?

The Nexus Automatic Routing feature attempts to discover what is available on proxy repository remotes by obtaining the set of path prefixes available. When this information can be obtained Nexus will use it to optimize request to the group repository, only querying repositories that it knows might contain the requested path.  It is important to understand that this feature is just an optimization, Nexus will function just fine in situations where remote routing rules cannot be detected.

There are two strategies used to detect what is available on a remote. First, if the remote is a Nexus instance it may publish a file under ".meta/prefixes.txt" which contains this information. This file has a format as follows:

## repository-prefixes/2.0
# Prefix file generated by Sonatype Nexus
# Do not edit, changes will be overwritten!

The remote will update this file whenever changes in it's stored artifacts require it.  Currently this file is published with two levels of directory information. On the proxy side, Nexus will periodically look for updates to this file according to the schedule specified in the proxy repository's "Routing" tab.

The other strategy used is that Nexus will scrape a published HTML directory listing to two levels deep if it is in a format which Nexus knows is reliable, such as an Apache web server.

A remote Nexus will only publish the prefixes.txt file for a repository when it can be 100% sure that it has complete information about what is contained in it.  If there is doubt then the prefixes.txt file will not be published.    Similarly, Nexus will only scrape an HTML directory listing if it is sure it is accurate.

If the remote is itself a proxy repository Nexus will only publish the prefixes.txt file if that proxy's remote has complete information.  And group repositories will only publish prefix information if all of their contained repositories do so.



Have more questions? Submit a request


Article is closed for comments.