+-
我可以在我的服务器端口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";
}
在这样做之后,我可以访问Nexus,但没有图片加载,javascript无法加载等等.查看Chrome的控制台,看起来Nexus想要访问以下网址:
https://HOST/static
https://HOST/service
https://HOST/repository
代替:
https://HOST/nexus/static
https://HOST/nexus/service
https://HOST/nexus/repository
我找不到任何方法来配置Nexus实际上全面利用基本URL功能.
我试过了:
>添加/删除X-Forwarded-Proto
>将位置设置为^〜/ nexus /
>启用和禁用proxy_redirect
但没有运气(不是我希望生成的URL基于nginx配置引用/ nexus,我想不出任何其他的尝试).
最后,我为/ static,/ service和/ repository添加了proxy_passes(假设我没有遗漏任何内容)并且乍一看它似乎工作,尽管我还没有尝试发布或其他很多.
Nexus不会正确使用Base URL我做错了什么?
最佳答案
如果您在nginx(或其他反向代理)后面运行nexus3的Docker化版本,则可以使用环境变量NEXUS_CONTEXT来设置新上下文.
例如在我的docker compose中:
nexus:
image: sonatype/nexus3:3.11.0
ports:
- 8081:8081
networks:
- my_net
environment:
NEXUS_CONTEXT: nexus
点击查看更多相关文章
转载注明原文:nginx – Nexus(3.2)基本URL被忽略? - 乐贴网