为离线的bcliunx euler&龙晰 配置 yum源 nginx代理

需求描述:

(1)192.168.10.201可以访问外网

(2)192.168.10.9 无法访问外网

(3) 在 192.168.10.201 上配置 nginx 代理(docker 容器启动), 代理http://mirrors.cmecloud.cn/bclinux/

(4)让 192.168.10.9 通过访问访问 192.168.10.202 的yum代理,可以访问到 yum 源。

一、192.168.10.2021操作步骤(部署 Nginx 容器反向代理)

1. 安装 Docker(BCLinux/openEuler 系统)

复制代码
# 安装docker
dnf install docker -y
# 开机自启+启动服务
systemctl enable --now docker
# 验证
docker info

2. 创建 Nginx 配置目录与代理配置文件

复制代码
# 新建配置存放目录
mkdir -p /etc/nginx_proxy/conf.d
# 编写反向代理配置
cat > /etc/nginx_proxy/conf.d/bclinux_repo.conf <<EOF
server {
    listen 80;
    server_name _;

    # 匹配内网访问路径 /bclinux/oe22.10/xxx
    location /bclinux/ {
        # 上游官方yum源地址
        proxy_pass http://mirrors.cmecloud.cn/bclinux/;
        proxy_set_header Host mirrors.cmecloud.cn;
        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 \$scheme;

        # 缓存可选(按需开启,加速重复下载)
        proxy_cache_valid 200 302 12h;
        proxy_cache_valid 404 5m;
    }
}
EOF

3. 启动 Nginx Docker 容器

复制代码
docker run -d \
  --name nginx-yum-proxy \
  --restart always \
  -p 80:80 \
  -v /etc/nginx_proxy/conf.d:/etc/nginx/conf.d \
  nginx:stable

4. 验证代理是否可用(在 201 本机测试)

复制代码
curl http://127.0.0.1/bclinux/oe22.10/OS/x86_64/
# 能返回yum源目录HTML列表,代表代理正常

二、验证yum代理

1. 配置/etc/hosts

bash 复制代码
192.168.10.201 mirrors.cmecloud.cn

2.编辑yum

vi /etc/yum.repos.d/BCLinux.repo

bash 复制代码
#generic-repos is licensed under the Mulan PSL v2.
#You can use this software according to the terms and conditions of the Mulan PSL v2.
#You may obtain a copy of Mulan PSL v2 at:
#    http://license.coscl.org.cn/MulanPSL2
#THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
#PURPOSE.
#See the Mulan PSL v2 for more details.

[OS]
name=OS
baseurl=http://mirrors.cmecloud.cn/bclinux/oe22.10/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-BCLinux-For-Euler

[everything]
name=everything
baseurl=http://mirrors.cmecloud.cn/bclinux/oe22.10/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-BCLinux-For-Euler

[EPOL]
name=EPOL
baseurl=http://mirrors.cmecloud.cn/openeuler/openEuler-22.10-LTS/EPOL/main/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cmecloud.cn/openeuler/openEuler-22.10-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

[debuginfo]
name=debuginfo
baseurl=http://mirrors.cmecloud.cn/bclinux/oe22.10/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-BCLinux-For-Euler

[update]
name=update
baseurl=http://mirrors.cmecloud.cn/bclinux/oe22.10/update/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-BCLinux-For-Euler

3.测试

bash 复制代码
[root@localhost yum.repos.d]# yum clean all
24 files removed
[root@localhost yum.repos.d]# yum grouplist
OS                                                                                                                                                                            1.3 MB/s | 3.5 MB     00:02
everything                                                                                                                                                                    2.4 MB/s |  17 MB     00:06
debuginfo                                                                                                                                                                     2.7 MB/s | 3.8 MB     00:01
update                                                                                                                                                                        2.3 MB/s |  18 MB     00:07
Last metadata expiration check: 0:00:01 ago on 2018年07月12日 星期四 19时10分43秒.
Available Environment Groups:
   带 GUI 的服务器
   服务器
   云服务器
   工作站
   定制操作系统
   虚拟化主机
   万维网服务器
   基础设施服务器
   GNOME 桌面
   开发及生成工作站
Installed Environment Groups:
   最小安装
Available Groups:
   图形管理工具
   RPM 开发工具
   控制台互联网工具
   .NET 核心开发
   Anolis OS cloud kernel
   Deepin New Desktop Environment
   容器管理
   开发工具
   无图形终端系统管理工具
   传统 UNIX 兼容性
   网络服务器
   科学记数法支持
   安全性工具
   系统工具
   智能卡支持
[root@localhost yum.repos.d]#
相关推荐
2601_962381138 小时前
历史视频朝代更替动效怎么做?把 AE 关键帧换成 AI 分镜动画的实战拆解
人工智能·nginx·音视频
数据杂坛10 小时前
【Python程序开发系列】一文搞清楚Gunicorn以及和Nginx的区别
python·nginx·gunicorn
锅巴编程10 小时前
nginx-413-client-max-body-size
运维·nginx
cpolar技术支持16 小时前
服务器上的 Nginx 只想改配置却不敢动?把 Nginx-UI 跑起来,用 MCP 让 AI 助手帮你安全改配置,再用 cpolar 把面板短时开给自己
nginx·ai·cpolar·mcp·nginx-ui
春天花会开1311 天前
内网 HTTPS 部署实战:私有 CA + Nginx 反向代理全流程复盘
运维·nginx·https
还是大剑师兰特6 天前
解决nginx错误:http://localhost:7000正常,http://localhost:7000/map 报错404
nginx·大剑师
xing-xing7 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
PC2005-cloud7 天前
Nginx 防盗链配置实战:用 referer 模块保护网站静态资源
nginx
PHP实战开发录7 天前
Nginx上传大文件为什么报413
nginx·php·开发
Lsetea7 天前
Nginx报No required SSL certificate was sent:mTLS客户端证书排查
运维·nginx·https·ssl·openssl