首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >执行从nexus3到nexus2的代理重定向时保留URL的NGINX配置,以使用解压缩插件

执行从nexus3到nexus2的代理重定向时保留URL的NGINX配置,以使用解压缩插件
EN

Stack Overflow用户
提问于 2019-05-15 21:01:18
回答 1查看 249关注 0票数 0

我已经从Nexus2迁移到Nexus3。但也有一个问题,nexus3不支持解压插件。因此,我想出的解决办法是部署一个nexus2容器,并将所有解压缩的repos代理到nexus2。然后当url以".zip-unzip“结尾时创建一个重定向链接,重定向到nexus2。这可以在nginx配置上完成。而且它还应该保留nexus3 url,但显示nexus2页面。

为此,我使用正则表达式定义了一个位置块,以匹配以".zip-unzip“结尾的urls和nexus2的代理传递。但它似乎不起作用。我也不确定如何让nexus2同时也是ssl加密的。

服务器{

代码语言:javascript
复制
listen 443 ssl;
server_name mt-nexus.psi-mt.de;
ssl_session_cache   shared:SSL:10m;
ssl_session_timeout 10m;
ssl_certificate /etc/nginx/conf.d/server.crt;
ssl_certificate_key /etc/nginx/conf.d/server.key;
include /etc/nginx/custom-errors.conf;  

client_max_body_size 1G;

    location / {
    proxy_pass http://nexus3:8081;
    proxy_set_header  Host  $http_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;
    proxy_read_timeout  900;        


}

location ~ ^"/nexus/(?<section>.+).zip-unzip$" {

proxy_pass http://nexus2:8081/$section.zip-unzip;
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";

}       
}

我希望当传递url "https://nexus3.xyz.com/nexus/content/repositories/Releases_Unzip/xxx.zip-unzip“时,它会重定向到nexus2URL链接"https://nexus2.xyz.com/nexus/content/repositories/Releases_Unzip/xxx.zip-unzip”,但保留了nexus3的url,即https://nexus3.xyz.com/...

EN

回答 1

Stack Overflow用户

发布于 2019-05-23 21:22:08

我自己解决的问题。您必须使用位置块,但是在使用代理传递时,位置块不支持使用"$“。因此,您必须在location块中使用重写,如下所示。

代码语言:javascript
复制
location ~ .zip-unzip/ {
            rewrite ^/nexus/(.*)$ /nexus/$1 break;
            proxy_pass http://nexus4unzip:8081;
            proxy_set_header Host $http_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;

        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56150034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档