nginx做yum源

我这边环境是原先有个nginx只是做了代理转发,现在需要在通过nginx做yum源方便后期安装源

1、原先的配置代理转发,为不影响原先配置及端口,在http中最末尾加“include /local/nginx/conf.d/*.conf;” 加载其它配置文件。
nginx所在服务器地址是10.7.12.10
#cat  /local/nginx/conf/nginx.conf 

user  nginx nginx;
worker_processes  1;

pid        /local/nginx/run/nginx/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                       '$upstream_addr $upstream_response_time $request_time ';
    log_format log404 '$status [$time_local] $remote_addr $host$request_uri $sent_http_location';

    access_log  logs/nginx/access.log main;
    access_log  logs/nginx/host.access.404.log  log404;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name localhost;
        large_client_header_buffers 4 128k;
        client_max_body_size 300m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        proxy_buffer_size 64k;
        proxy_buffers   4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;

        location /status{
                stub_status on;
                access_log on;
                auth_basic "status";
                auth_basic_user_file htpasswd;
        }

        location /nk {
           index  index.html index.htm index.jsp;
           proxy_pass      http://10.7.12.15:8081/nk;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header Host $host:$server_port;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

     include /local/nginx/conf.d/*.conf;     #加载其它配置文件

    }
2、在 /local/nginx/conf.d/目录下建个yumrepo.conf配置文件,定义server
#vi /local/nginx/conf.d/yumrepo.conf 

    server {
        listen       8022;
        server_name  localhost;
        large_client_header_buffers 4 128k;
        client_max_body_size 300m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        proxy_buffer_size 64k;
        proxy_buffers   4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /yumrepo/Yumdate/rhel6;
            index  index.html index.htm;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
   }

}

将镜像文件里面所有包拷贝到/yumrepo/Yumdate/rhel6目录下
nginx做yum源

重新reload一下nginx即可,页面可以访问看看http://IP:端口号:
nginx做yum源

3、编辑自己的repo文件
#vi /etc/yum.repos.d/yum.repo 
[yumku]
name=yumku Red Hat 6.2x64 repo
baseurl=http://10.7.12.10:8022    #yum源所在服务器IP及端口,如果端口为80直接写IP即可
enable=1
gpgcheck=0

yum list 查看yum是否可用
yum clean all 清除缓存

4、rhel7.5搭建nginx的YUM源

将镜像文件里面所有包拷贝到/yumrepo/Yumdate/rhel7目录下
主要是将Packages repodata这两个目录整个拷贝过去,在将RPM-GPG开头的认证文件拷贝自己创建GPG-KEY目录下即可
nginx做yum源

5、reh7.5下编辑自己repo文件(nginx这里用是默认80端口)
vi /etc/yum.repos.d/jj.repo 
[JJKRepo]
name=JJ RedHat7.5X64 Repo
baseurl=http://IP
gpgcheck=0
enabled=1
gpgkey=http://ip/GPG-KEY/RPM-GPG-KEY-redhat-release

至此nginx做yum源已搭建完成!!!

转载于:https://blog.51cto.com/meiling/2069005

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值