公司有一台电脑A不能访问外网,需要在这台电脑上安装软件,使用yum安装,可以自动安装匹配的版本,在网上查了下可以使用http代理,刚好另外一台电脑B可以访问外网并安装nginx,于是增加照着配置了一下,给电脑B增加下面两个代理
server {
listen 80;
server_name localhost;#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
location /centos/ {
proxy_pass http://mirrors.aliyun.com/centos/;
proxy_max_temp_file_size 0;
}
location /kubernetes/ {
proxy_pass http://mirrors.aliyun.com/kubernetes/;
proxy_max_temp_file_size 0;
}
说明一下,刚开始没有添加 proxy_max_temp_file_size,下载软件经常碰到[Errno 14] curl#18 - "transfer closed with xxx bytes remaining to read"的错误,开始还以为电脑A还需要进行其他配置,后面试了了小软件git,发现安装成功了,才注意到是rpm包没下载完,然后在网上搜这个[Errno 14] curl#18的解决方法,参考下面的文章添加了该参数,之前没下载完的rpm包接着都下载完成了。
参考连接:https://blog.csdn.net/qq_21127151/article/details/90549080
补充电脑A的yum源修改方法:
将mirrors.aliyun.com修改成电脑B的IP
[kubernetes]
name=Kubernetes
baseurl=http://电脑B的IP/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=http://电脑B的IP/kubernetes/yum/doc/yum-key.gpg http://电脑B的IP/kubernetes/yum/doc/rpm-package-key.gpg