nginx反向代理进行yum配置的步骤详解
发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,part.0 使用背景公司内网服务器不能直接通过Internet上网,但为了与外网通信和同步时间等,会指定那么几台服务器可以访问Internet。这里就是通过能上网的机器作为代理,制作内网使用的yum
千家信息网最后更新 2024年09月23日nginx反向代理进行yum配置的步骤详解
part.0 使用背景
公司内网服务器不能直接通过Internet上网,但为了与外网通信和同步时间等,会指定那么几台服务器可以访问Internet。这里就是通过能上网的机器作为代理,制作内网使用的yum仓库。
part.1 环境
内网dns(推荐,非必须,因为可使用IP代替)
一台能上Internet的服务器A
不能上Internet的服务器能与A服务器通信
part.2 nginx安装
在可连接外网的A中安装nginx
yum install nginx
part.3 nginx配置
在主机A中添加nginx配置
$ cd /etc/nginx/conf.d$ vim proxy.conf
server { listen 80; #listen [::]:80; server_name mirrors.yourdomain.com; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/html; location /ubuntu/ { proxy_pass http://mirrors.aliyun.com/ubuntu/ ; } location /centos/ { proxy_pass http://mirrors.aliyun.com/centos/ ; } location /epel/ { proxy_pass http://mirrors.aliyun.com/epel/ ; } }
part.4 配置yum repo 源
修改无法连接外网的主机B 的repo文件。
$ cat /etc/yum.repos.d/CentOS-7.repo
[base]name=CentOS-$releasever - Base - mirrors.yourdomain.comfailovermethod=prioritybaseurl=http://mirrors.yourdomain.com/centos/$releasever/os/$basearch/ http://mirrors.yourdomain.com/centos/$releasever/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7#released updates [updates]name=CentOS-$releasever - Updates - mirrors.yourdomain.comfailovermethod=prioritybaseurl=http://mirrors.yourdomain.com/centos/$releasever/updates/$basearch/ http://mirrors.yourdomain.com/centos/$releasever/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.yourdomain.comfailovermethod=prioritybaseurl=http://mirrors.yourdomain.com/centos/$releasever/extras/$basearch/ http://mirrors.yourdomain.com/centos/$releasever/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - mirrors.yourdomain.comfailovermethod=prioritybaseurl=http://mirrors.yourdomain.com/centos/$releasever/centosplus/$basearch/ http://mirrors.yourdomain.com/centos/$releasever/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.yourdomain.comfailovermethod=prioritybaseurl=http://mirrors.yourdomain.com/centos/$releasever/contrib/$basearch/ http://mirrors.yourdomain.com/centos/$releasever/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7
part.5 配置hosts
$ cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.193 mirrors.yourdomain.com# 确保A 主机IP 和后面的反向代理地址
part.6 配置iptables
ping mirrors.yourdomain.com#报错 没有到主机的路由
此时查看B主机中的iptables信息,发现无法访问80,可以在最前添加一条规则。
$ iptables -nvL 8155 28M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 11761 985K INPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0 11761 985K INPUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0 11761 985K INPUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID11756 985K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
$ iptables -I INPUT -p tcp --dport 80 -j ACCEPT
part.7 测试是否成功
在B主机中进行,yum makecache操作。来判断是否能进行yum操作。
$ yum clean all$ yum makecache
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对的支持。
主机
配置
服务器
服务
代理
内容
就是
学习
成功
仓库
价值
信息
公司
地址
文件
时间
机器
环境
疑问
篇文章
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
那种软件开发模式具有抗风险
二级数据库教程
自己创建数据库
优e家服务器未连接到云端
哪个软件开发公司靠谱
松江区软件开发项目管理
2021年的网络安全周是
阿里巴巴网络技术域名纠纷案
阿里云服务器管理面板
明晓网络技术有限公司
安徽综合软件开发出厂价格
北京易拍网络技术有限公司
如何把文件上传到服务器
net获取服务器ip
精灵觉醒服务器维修
安全如何计算机网络安全
怎么看摩尔庄园是什么服务器
湖北大数据软件开发定制
网络安全昌平综合台
设置窗体标题数据库
魔兽世界怎么切换人多的服务器
首款面向云计算的服务器
it软件开发软件开发
计算机软件开发规划书
面试题数据库查询优化
花雨庭服务器的作用
云服务器连接端口在哪里看
数据库怎么打开查询分析器
网络安全就在身边
清华同方中文系列数据库