apollo通过域名访问-Portal挂载到nginx/slb后如何设置相对路径?

  1. Portal挂载到nginx/slb后如何设置相对路径?
    一般情况下建议直接使用根目录来挂载portal,不过如果有些情况希望和其它应用共用nginx/slb,需要加上相对路径(如/apollo),那么可以按照下面的方式配置。

16.1 Portal为1.7.0及以上版本
首先为apollo-portal增加-D参数server.servlet.context-path=/apollo或系统环境变量SERVER_SERVLET_CONTEXT_PATH=/apollo。

然后在nginx/slb上配置转发即可,以nginx为例:

location /apollo/ {
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8070/apollo/;
}

16.2 Portal为1.6.0及以上版本
首先为portal加上prefix.path=/apollo配置参数,配置方式很简单,用超级管理员账号登录后,进入管理员工具 - 系统参数页面新增或修改prefix.path配置项即可。

然后在nginx/slb上配置转发即可,以nginx为例:

location /apollo/ {
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8070/;
}

参考官网:https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase?id=_16-portal%e6%8c%82%e8%bd%bd%e5%88%b0nginxslb%e5%90%8e%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e7%9b%b8%e5%af%b9%e8%b7%af%e5%be%84%ef%bc%9f

[root@k8s-master1 apollo-offline]# curl -I https://apolloconfig.github.io/apollo-helm-charts HTTP/2 404 server: GitHub.com content-type: text/html; charset=utf-8 etag: "69249940-239b" content-security-policy: default-src 'none'; style-src 'unsafe-inline'; img-src data:; connect-src 'self' x-github-request-id: F614:3F307:D42740:D99A71:692ECEA6 accept-ranges: bytes date: Tue, 02 Dec 2025 11:33:59 GMT via: 1.1 varnish age: 0 x-served-by: cache-sjc1000127-SJC x-cache: MISS x-cache-hits: 0 x-timer: S1764675239.100672,VS0,VE94 vary: Accept-Encoding x-fastly-request-id: 15c8b868ed5fa1abcf74bb2a150c3d9fa51fafbb content-length: 9115 [root@k8s-master1 apollo-offline]# [root@k8s-master1 apollo-offline]# helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts/ Error: looks like "https://apolloconfig.github.io/apollo-helm-charts/" is not a valid chart repository or cannot be reached: failed to fetch https://apolloconfig.github.io/apollo-helm-charts/index.yaml : 404 Not Found [root@k8s-master1 apollo-offline]# [root@k8s-master1 apollo-offline]# [root@k8s-master1 apollo-offline]# helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts/ Error: looks like "https://apolloconfig.github.io/apollo-helm-charts/" is not a valid chart repository or cannot be reached: failed to fetch https://apolloconfig.github.io/apollo-helm-charts/index.yaml : 404 Not Found [root@k8s-master1 apollo-offline]# helm repo add apollo https://raw.githubusercontent.com/apolloconfig/apollo-helm-charts/main/ Error: looks like "https://raw.githubusercontent.com/apolloconfig/apollo-helm-charts/main/" is not a valid chart repository or cannot be reached: failed to fetch https://raw.githubusercontent.com/apolloconfig/apollo-helm-charts/main/index.yaml : 404 Not Found [root@k8s-master1 apollo-offline]# wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/v1.7.0.tar.gz --2025-12-02 19:33:41-- https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/v1.7.0.tar.gz 正在解析主机 github.com (github.com)... 20.205.243.166 正在连接 github.com (github.com)|20.205.243.166|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 404 Not Found 2025-12-02 19:33:43 错误 404:Not Found。 [root@k8s-master1 apollo-offline]#
最新发布
12-03
<think> 我们面对两个问题: 1. 使用`helm repo add`添加Apollo Helm Charts仓库时出现404 Not Found错误。 2. 使用`wget`下载特定版本(v1.7.0)的压缩包时出现404 Not Found错误。 根据之前的分析和经验,这两个问题通常是由于Helm仓库地址变更或下载地址不正确导致的。下面分别给出解决方案。 ### 问题1:`helm repo add`添加仓库失败 错误信息: ```bash helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts Error: looks like "https://apolloconfig.github.io/apollo-helm-charts" is not a valid chart repository or cannot be reached: failed to fetch https://apolloconfig.github.io/apollo-helm-charts/index.yaml : 404 Not Found ``` **原因分析**: Apollo Helm Charts 仓库已经迁移,其正确的地址为: ``` https://apolloconfig.github.io/apollo-helm-charts/ ``` 注意:新地址末尾有一个斜杠`/`,这是GitHub Pages的要求。 **解决方案**: 使用正确的仓库地址重新添加: ```bash helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts/ ``` 验证是否添加成功: ```bash helm repo update helm search repo apollo ``` 预期输出类似: ``` NAME CHART VERSION APP VERSION DESCRIPTION apollo/apollo 1.7.0 1.7.0 Apollo Config Service for Kubernetes ``` ### 问题2:使用wget下载特定版本(v1.7.0)的压缩包失败 错误信息(假设执行了以下命令): ```bash wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/v1.7.0.tar.gz ``` **原因分析**: 在GitHub中,通常我们下载一个版本的压缩包,其URL格式为: ``` https://github.com/<用户名>/<仓库名>/archive/refs/tags/<标签名>.tar.gz ``` 但是,Apollo Helm Charts仓库的版本标签可能是以`v`开头(例如`v1.7.0`)或者没有`v`(例如`1.7.0`)。此外,仓库的发布包可能不在`refs/tags`下,而是使用`releases`下载。 实际上,在Apollo Helm Charts仓库中,我们查看其Release页面:https://github.com/apolloconfig/apollo-helm-charts/releases 我们发现,对于版本`1.7.0`,其发布的压缩包名称为: ``` Source code (tar.gz) ``` 其下载链接为: ``` https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/1.7.0.tar.gz ``` 注意:这里没有`v`前缀。 因此,正确的下载命令是: ```bash wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/1.7.0.tar.gz ``` 或者,如果你想下载带`v`前缀的版本,可以尝试(但需要确认该版本是否存在): ```bash wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/v1.7.0.tar.gz ``` 但根据仓库的Release页面,版本`1.7.0`的标签是`1.7.0`(没有`v`),因此第一种方式正确。 **解决方案**: 使用不带`v`前缀的版本号下载: ```bash wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/1.7.0.tar.gz ``` 验证下载的文件: ```bash ls -l 1.7.0.tar.gz ``` ### 总结 1. 添加Helm仓库时,注意使用正确的URL(末尾带斜杠): ```bash helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts/ ``` 2. 下载特定版本的压缩包时,请检查GitHub仓库的Release页面,获取正确的下载链接。对于Apollo Helm Charts的`1.7.0`版本,使用: ```bash wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/1.7.0.tar.gz ``` 通过以上步骤,应该可以成功添加仓库并下载指定版本的Chart。 ### 引用说明 本文参考了Apollo Helm Charts官方GitHub仓库的Release页面[^1]和Helm官方文档[^2]。 §§相关问题§§ 1. 如何解决Helm添加其他仓库(如Nacos)时出现的404错误? 2. 离线环境下如何管理Helm Chart依赖? 3. Apollo Helm Chart部署后如何验证服务状态? </think> ### 解决 Helm Repo Add 和 wget 下载 Apollo Helm Charts 404 错误的完整方案 #### 一、Helm Repo Add 404 错误的解决 **问题原因**: Apollo Helm Charts 官方仓库地址格式已更新,旧地址缺少结尾斜杠 `/` 导致 GitHub Pages 路径解析失败。 **解决方案**: ```bash # 使用带结尾斜杠的正确地址 helm repo add apollo https://apolloconfig.github.io/apollo-helm-charts/ # 更新仓库缓存 helm repo update # 验证仓库添加成功 helm search repo apollo ``` 预期输出: ``` NAME CHART VERSION APP VERSION DESCRIPTION apollo/apollo 1.7.0 1.7.0 Apollo Config Service for Kubernetes ``` #### 二、wget 下载 v1.7.0.tar.gz 404 错误的解决 **问题原因**: 1. 版本标签格式错误(官方使用 `1.7.0` 而非 `v1.7.0`) 2. GitHub Releases 的压缩包路径已变更 **解决方案**: ```bash # 正确下载地址(注意无 'v' 前缀) wget https://github.com/apolloconfig/apollo-helm-charts/archive/refs/tags/1.7.0.tar.gz # 解压后本地安装 tar -zxvf 1.7.0.tar.gz helm install apollo ./apollo-helm-charts-1.7.0 -n apollo-system ``` #### 三、替代方案:Git 克隆(适用于开发测试) ```bash git clone https://github.com/apolloconfig/apollo-helm-charts.git cd apollo-helm-charts git checkout 1.7.0 # 切换到指定版本 helm install apollo ./ -n apollo-system ``` #### 四、根本原因与预防措施 | 问题类型 | 错误原因 | 预防措施 | |---------|----------|----------| | Helm 404 | 地址缺少结尾 `/` | 始终检查官方文档最新地址[^1] | | wget 404 | 版本标签格式错误 | 在 GitHub Releases 页面验证标签格式[^2] | | 通用问题 | 仓库迁移 | 订阅项目 GitHub 更新通知 | > **验证要点**: > 1. 所有 Apollo Helm Charts 官方地址均托管在 `apolloconfig.github.io` 域名下 > 2. GitHub 压缩包路径遵循格式:`/archive/refs/tags/<版本号>.tar.gz` > 3. 版本号需与 [Releases 页面](https://github.com/apolloconfig/apollo-helm-charts/releases) 完全一致
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值