nexus 代理 pypi

环境说明

服务 ip 端口 备注
nexus 192.168.80.129 (内网) 8081 内网地址无法访问外网
nginx

192.168.80.128 (内网)

192.168.174.126 (外网)

 88

19000

192.168.174.126 地址可以访问外网

创建 Blob Stores

创建 Repositories

设置 proxy

repo 测试

# pip install xlrd -i http://192.168.80.129:8081/repository/pypi-aliyun-repo/simple/ --trusted-host 192.168.80.129
Collecting xlrd
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-repo/packages/xlrd/2.0.1/xlrd-2.0.1-py2.py3-none-any.whl (96kB)
    100% |████████████████████████████████| 102kB 102.9MB/s 
Installing collected packages: xlrd
Successfully installed xlrd-2.0.1
# pip install pandas -i http://192.168.80.129:8081/repository/pypi-aliyun-repo/simple/ --trusted-host 192.168.80.129
Looking in indexes: http://192.168.80.129:8081/repository/pypi-aliyun-repo/simple/
Collecting pandas
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-repo/packages/pandas/2.2.1/pandas-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.0/13.0 MB 81.4 MB/s eta 0:00:00
Collecting numpy<2,>=1.23.2 (from pandas)
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-repo/packages/numpy/1.26.4/numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 72.9 MB/s eta 0:00:00
Collecting python-dateutil>=2.8.2 (from pandas)
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-repo/packages/python-dateutil/2.9.0.post0/python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB 64.2 MB/s eta 0:00:00
Requirement already satisfied: pytz>=2020.1 in /usr/lib/python3/dist-packages (from pandas) (2023.3)
Collecting tzdata>=2022.7 (from pandas)
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-repo/packages/tzdata/2024.1/tzdata-2024.1-py2.py3-none-any.whl (345 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 79.0 MB/s eta 0:00:00
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Installing collected packages: tzdata, python-dateutil, numpy, pandas
Successfully installed numpy-1.26.4 pandas-2.2.1 python-dateutil-2.9.0.post0 tzdata-2024.1

查看

不启用 http proxy 的方法

Repositories 设置

nginx 配置

server {
    listen       19000;
    server_name  localhost;
    #resolver 202.106.0.20 ipv6=off;
    # 设置代理访问日志
    access_log  logs/proxy.access.log ;
    error_log  logs/proxy.error.log ;

    location /pypi {
    	proxy_pass https://mirrors.aliyun.com;
  
    }
}

测试 repo

# pip install xlrd -i http://192.168.80.129:8081/repository/pypi-aliyun-1-repo/simple --trusted-host 192.168.80.129
Collecting xlrd
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-1-repo/packages/xlrd/2.0.1/xlrd-2.0.1-py2.py3-none-any.whl (96kB)
    100% |████████████████████████████████| 102kB 72.5MB/s 
Installing collected packages: xlrd
Successfully installed xlrd-2.0.1
# pip install tzdata -i http://192.168.80.129:8081/repository/pypi-aliyun-1-repo/simple --trusted-host 192.168.80.129
Collecting tzdata
  Downloading http://192.168.80.129:8081/repository/pypi-aliyun-1-repo/packages/tzdata/2024.1/tzdata-2024.1-py2.py3-none-any.whl (345kB)
    100% |████████████████████████████████| 348kB 123.7MB/s 
Installing collected packages: tzdata
Successfully installed tzdata-2024.1

查看

参考文档

https://help.sonatype.com/en/pypi-repositories.html

posted @ 2024-03-31 14:13  小吉猫  阅读(182)  评论(0编辑  收藏  举报