Nexus(3.2)基本网址被忽略了吗?

Cra*_*aig 5 nginx nexus

我可以在端口8081的服务器上运行Nexus 3.2.0-01,但是我想将其作为https:// HOST / nexus /运行,通过nginx反向代理。

根据文档,我需要设置一个基本URL功能。然后,将其添加到我的nginx配置中:

location /nexus/ {
    proxy_pass http://localhost:8081/;

    # Rewrite HTTPS requests from WAN to HTTP requests on LAN                   
    proxy_redirect http:// https://;

    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto "https";
}
Run Code Online (Sandbox Code Playgroud)

完成此操作后,我可以访问Nexus,但无法加载图片,无法加载javascript等。查看Chrome的控制台后,Nexus似乎要访问以下网址:

https://HOST/static
https://HOST/service
https://HOST/repository
Run Code Online (Sandbox Code Playgroud)

代替:

https://HOST/nexus/static
https://HOST/nexus/service
https://HOST/nexus/repository
Run Code Online (Sandbox Code Playgroud)

我找不到任何方法可以配置Nexus来全面利用Base URL功能。

我试过了:

  • 添加/删除X-Forwarded-Proto
  • 将位置设置为^〜/ nexus /
  • 启用和禁用proxy_redirect

但是没有运气(不是我希望生成的URL基于nginx配置引用/ nexus,我想不出要尝试的其他方法)。

最后,我为/ static,/ service和/ repository添加了proxy_passes(假设我没有遗漏任何东西),乍一看它似乎可以工作,尽管我还没有尝试发布或做过很多尝试。

Nexus无法正确使用基本网址,我在做什么错?

4lb*_*rto 6

如果您在 nginx(或其他反向代理)后面运行 Dockerized 版本的 nexus3,您可以使用环境变量 NEXUS_CONTEXT 来设置新上下文。

例如在我的 docker 中:

nexus:
   image: sonatype/nexus3:3.11.0
   ports:
     - 8081:8081
   networks:
     - my_net
   environment:
      NEXUS_CONTEXT: nexus
Run Code Online (Sandbox Code Playgroud)


rse*_*don 3

如果您想在“/”以外的上下文路径上运行 Nexus,则必须调整 Nexus 实际运行的上下文路径。编辑“sonatype-work/nexus3/etc/nexus.properties 并设置“nexus-context-path=/nexus”。请参阅此处了解我们的其他建议:

http://books.sonatype.com/nexus-book/reference3/index.html