为离线的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_9656196914 小时前
AI视频制作:财经数据可视化视频怎么做:AI 自动生成图表动画的实操流程
人工智能·nginx·音视频
2601_9656196914 小时前
历史解说视频怎么做:青铜器瓷器文物画面自动对齐的完整教程
运维·nginx·音视频
姜鱼问生1 天前
每次开机手动检查 6 样东西?我写了个 2 秒自检脚本
运维·网络·nginx·docker·容器
xixingzhe22 天前
Nginx 看懂请求耗时瓶颈
服务器·前端·nginx
北风toto2 天前
Windows 下用 OpenSSL 生成 SSL 密钥并配置 Nginx 教程
windows·nginx·ssl
卜锦元2 天前
Docker Compose 部署 Nginx 1.30.6 完整指南
nginx·docker·容器
小小龙学IT2 天前
Nginx 开源 Web 服务器与反向代理深度解
前端·nginx·开源
Coisinier3 天前
docker命令管理镜像及容器
linux·运维·nginx·docker·容器·操作系统
2301_32241428043 天前
基于web的校园失物招领管理系统59695-计算机毕设 原创(免费领源码+部署教程+开发环境)
mysql·nginx·php·apache·thinkphp·phpstudy·wampserver
flytalei3 天前
从YAML到Nginx服务访问:动手理解 Kubernetes Pod、Deployment 与 Service
运维·nginx·kubernetes