Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-31669

service/local/<repoid>/content URLs do not work even when legacy URL capability is enabled

    Details

    • Notability:
      3

      Description

      Setup

      • the webapp context path is configured as /nexus in repo 2 and repo 3
      • a "central" proxy to Central is installed in repo 3
      • the default "central" proxy repo is installed in repo 2
      • The NXRM2 legacy URL capability is enabled in repo 3

      Test legacy "service/local" content URLs:

      URL: http://localhost:8081/nexus/service/local/repositories/central/content/abbot/abbot/0.13.0/abbot-0.13.0.pom

      • Repo 2 this works - 200
      • Repo 3, with legacy URL capability enabled, this DOES NOT WORK - 404: UNEXPECTED

      URL: http://localhost:8081/nexus/service/local/repositories/central/abbot/abbot/0.13.0/abbot-0.13.0.pom

      • Repo 2, this DOES NOT WORK - 404 not found:
      • Repo 3 with legacy URL capability enabled, this DOES WORK - 200: UNEXPECTED

      Expected

      As /service/local/repositories/<repoid>/content was a valid URL in repo 2, then the legacy URL capability in repo 3 should implement support for that URL, instead of /service/local/repositories/maven-central/ .

      Workaround

      Workaround is possible with a custom Jetty handler - this solution should continue to work although this workaround is provided AS IS, not officially supported, not as a feature and it may break at any time in the future.

      Put the following content into a file at <APP-DIR>/etc/jetty/jetty-service-local-legacy-rewrite.xml

       
      <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
      <Configure id="Server" class="org.eclipse.jetty.server.Server">
      
        <!-- Sonatype Issue https://issues.sonatype.org/browse/NEXUS-31669 -->
        
        <Ref refid="Handlers">
          <Call name="prependHandler">
            <Arg>
              <New id="service-local-legacy-rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
                <Set name="rewriteRequestURI">true</Set>
                <Set name="rewritePathInfo">false</Set>
                <Call name="addRule">
                  <Arg>
                    <New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
                      <Set name="regex">/service/local/repositories/(.*)/content/(.*)</Set>
                      <Set name="replacement">/repository/$1/$2</Set>
                    </New>
                  </Arg>
                </Call>
              </New>
            </Arg>
          </Call>
        </Ref>
      </Configure>
       

      Then edit sonatype-work/nexus3/etc/nexus.properties to add reference to the file via nexus-args - example editing the default nexus-args value:

      nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml,${jetty.etc}/jetty-service-local-legacy-rewrite.xml
      

      Then startup repo 3 - this should allow the original stye content urls to work in repo 3.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              plynch Peter Lynch
              Last Updated By:
              Peter Lynch Peter Lynch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  tigCommentSecurity.panel-title