nginx代理yum
适用场景:有多台服务器,但是只有1台服务器可以出公网,此时即可使用如下方式,进行yum代理,解决内网服务器不能yum的尴尬。
一、首先需要把/etc/yum.repos.d下的文件备份到bak,然后留一个CentOS-Base.repo。编辑这个文件,我使用的是科大的yum源。
如下代码:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
################################################################
二、然后需要编辑内网服务器另一个配置文件:vi /etc/yum.conf 需要注意 proxy=http://172.21.7.20:3621,这里是配置代理的ip和端口,就是可出公网的那台服务器的nginx端口。
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
proxy=http://172.21.7.20:3621
http_caching=none
# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
################################################################
三、设置nginx代理
在可出公网的那台服务器设置nginx代理:添加如下配置
server {
listen 3621;
#禁用multipart range功能
max_ranges 1;
server_name _;
server_tokens off;
location / {
access_log /data3/log1/nginx/mirrors.log;
proxy_pass http://mirrors.ustc.edu.cn;
}
}
保存,退出,重启nginx。
此时在内网服务器上执行yum makecache fast,之后内网服务器就可以正常使用yum了,再也不用上传5G的镜像资源挂载了!!!!
nginx代理yum的更多相关文章
- 使用nginx代理centos yum 源
我们在安装centos 服务器时,可能会有以下情况: 局域网内有若干台服务器,但是只有一台服务器可以连接外网,其余服务器都不可以连接外网,但通过局域网与外网机器联通. 那么我们再使用 yum 安装软件 ...
- Nginx反向代理YUM请求
一.安装配置Nginx服务(Nginx服务器上建议先关闭iptables/firewalld服务,待实验完成后再根据实际情况配置) [root@localhost ~]# yum install ng ...
- CentOS 7 安装Subversion, 并用Nginx代理
环境:CentOS 7.3.1611 分三步:第一步:安装subversion第二步:安装httpd第三步:安装nginx 操作步骤: 安装subversion, 命令 -> yum -y in ...
- Nginx代理TCP服务
利用nginx代理tpc 部署nginx 安装编译所需环境 # yum install -y apr-devel apr-util-devel pcre-devel openssl-devel 添加w ...
- Nginx代理转发Apache+svn
1.安装svn和httpd yum install httpd yum install subversion mod_dav_svn 创建仓库目录 mkdir -p /var/www/svn 3.创建 ...
- nginx做yum源
我这边环境是原先有个nginx只是做了代理转发,现在需要在通过nginx做yum源方便后期安装源 1.原先的配置代理转发,为不影响原先配置及端口,在http中最末尾加“include include ...
- Nginx代理MysqlCluster集群(二)
Nginx代理MySql集群本次实验采用nginx 版本1.12以上 集合了tcp代理功能只需在编译时明文开启指定的功能 --with-stream--prefix=/usr/local/ngin - ...
- FastDFS + Nginx代理方式访问
FastDFS + Nginx代理方式访问 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.在storage上安装nginx 1>.下载nginx软件(http://ngi ...
- Docker Compose 一键部署Nginx代理Tomcat集群
Docker Compose 一键部署Nginx代理Tomcat集群 目录结构 [root@localhost ~]# tree compose_nginx_tomcat/ compose_nginx ...
随机推荐
- fzu2280 Magic(暴力+哈希预处理)
传送门 题意 q次操作,每次两种操作: 1 x y:将wx变成y 2 x:查询满足一下两个条件的字符串(①以字符串x为后缀②字符串值\(\le wx\)) 分析 对n个字符串预处理,设f[i][j]为 ...
- AssetDatabase文档翻译
AssetDatabase是一个能获取工程资源的API,它提供一些方法比如:查找.加载.创建.删除和修改.Unity需要了解工程文件夹里的所有改变,假如想要获取或修改资源文件,就使用 AssetDat ...
- bzoj 1031: [JSOI2007]字符加密Cipher【后缀数组】
算是SA的裸题了 把串复制一遍接在原串后面,然后求SA,然后按着SA的顺序输出尾字符即可 #include<iostream> #include<cstdio> #includ ...
- bzoj4145 [AMPPZ2014]The Prices(状压dp)
Description 你要购买m种物品各一件,一共有n家商店,你到第i家商店的路费为d[i],在第i家商店购买第j种物品的费用为c[i][j], 求最小总费用. Input 第一行包含两个正整数n, ...
- HTTP请求头中的那些东西
一.HTTP请求头是什么? HTTP请求头,HTTP客户程序(例如浏览器),向服务器发送请求的时候必须指明请求类型(一般是GET或者POST).如有必要,客户程序还可以选择发送其他的请求头. 二.HT ...
- dwr学习 之 一、dwr+spring的简单集成
1. 环境搭建 我采用的环境为SpringMVC + myBatis + mySql + maven: 关于使用Eclipse构建Maven的SpringMVC项目,请参考: http://limin ...
- Apache Zeppelin是什么?
Apache Zeppelin提供了web版的类似ipython的notebook,用于做数据分析和可视化.背后可以接入不同的数据处理引擎,包括spark, hive, tajo等,原生支持scala ...
- JSP | 基础 | JSP状态管理 | Cookie
Cookie : 是web服务器保存在客户端的一系列文本信息. Cookie的作用: 1.对特定的对象的追踪 2. 3. JSP中创建Cookie以及使用 创建Cookie对象 写入Cookie对象 ...
- php.ini配置文件位置
laravel之今天遇到个意想不到的问题: 我在测试文件上传,大于2M的文件时候hasFile() 方法报错,这一定是文件大小限制.接下来就跳坑了 1.首先查找php.ini的位置,就用find / ...
- iOS中自定义UITableViewCell的用法
1.先创建一个View继承 UITableViewCell并使用xib快速建立模型. #import <UIKit/UIKit.h> #import "Score.h" ...