# nginx.conf log_format 添加  "$upstream_cache_status" 命中状态

proxy_cache_path /data/cache levels=1:2 keys_zone=rpm-cache:50m max_size=20g inactive=365d use_temp_path=off; 
proxy_cache_path /data/repo levels=1:2 keys_zone=repo-cache:50m max_size=1g inactive=1d use_temp_path=off; 
proxy_redirect off;
proxy_connect_timeout 30;
proxy_cache_valid  200 304 302 24h;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; #后端超时使用缓存的数据
add_header X-Cache-Status $upstream_cache_status;
server_tokens off;

server {
    listen 80;

    root html;
    index index.html index.htm index.php;
    location / {
            return 404;
    }

    location ~ (\.iso|\.filez|\.dirtree|\.png|\.gif)$ {
            return 403;
    }

    location /itv/ {
        alias /data/itv/;
    }

    location /base/ {
        set $key rpm-cache;
        if ( $uri ~* repodata ){
            set $key repo-cache;
        }
        proxy_pass http://mirrors.aliyun.com/centos/;
        proxy_cache $key;
    }

    location /epel/ {
                set $key rpm-cache;
                if ( $uri ~* repodata ){
                        set $key repo-cache;
                }
                proxy_pass http://mirrors.aliyun.com/epel/;
                proxy_cache $key;
        }
}


repo文件
[iTV]
name=iTV
baseurl=http://192.168.41.21/itv/$releasever/$basearch/
enabled=1
gpgcheck=0

[iTV-base]
name=iTV-base
baseurl=http://192.168.41.21/base/$releasever/os/$basearch/
enabled=1
gpgcheck=0


[iTV-updates]
name=iTV-updates
baseurl=http://192.168.41.21/base/$releasever/updates/$basearch/
enabled=1
gpgcheck=0

[iTV-extras]
name=iTV-extras
baseurl=http://192.168.41.21/base/$releasever/extras/$basearch/
enabled=1
gpgcheck=0

[iTV-epel]
name=iTV-epel
baseurl=http://192.168.41.21/epel/$releasever/$basearch/
enabled=1
gpgcheck=0

results matching ""

    No results matching ""