【问题标题】:Stuggling to set up caching for PyPi server via NGINX/UWSGI努力通过 NGINX/UWSGI 为 PyPi 服务器设置缓存
【发布时间】:2020-07-10 15:19:11
【问题描述】:

我正在尝试通过 NGINX/uWSGI 配置 PyPi 服务器的缓存,但失败得很惨。

我的/sites-available/pypi 配置如下:

uwsgi_cache_path /mnt/pypi/nginx-cache
                 levels=1:2
                 keys_zone=pypiserver_cache:10m
                 max_size=10g
                 inactive=60m
                 use_temp_path=off;

server {
    listen 80 default_server;
    listen 443 default_server ssl;
    ssl_certificate     /etc/ssl/certs/domain.pem;
    ssl_certificate_key /etc/ssl/private/domain.key;

    client_max_body_size 5M;

    location / {
        uwsgi_cache pypiserver_cache;
        uwsgi_buffering on;
        uwsgi_cache_key $request_uri;
        add_header X-uWSGI-Cache $upstream_cache_status;
        include uwsgi_params;
        uwsgi_pass unix:/run/uwsgi/internal_pypi.socket;
    }
}

NGINX 运行并没有报告错误,但多次请求同一个包并不会缓存它(通过 curl URL 并观察标头 X-uWSGI-Cache: MISS 来证明)并且在 /mnt/pypi/nginx-cache 中没有存储任何内容。

如果我能提供更多有用的信息,请告诉我,谢谢!

参考资料:

【问题讨论】:

    标签: nginx uwsgi pypi


    【解决方案1】:

    这已解决,在我的情况下,pypi 服务器 python 文件需要一些更改。

    application = pypiserver.app(
        root="/mnt/pypi/directory",
        redirect_to_fallback=False,
        password_file="path/to/file",
        cache_control=3600 #this needed to be added
    )
    

    【讨论】:

      猜你喜欢
      • 2015-09-29
      • 2011-03-12
      • 2016-06-07
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 2019-03-15
      • 2013-04-27
      相关资源
      最近更新 更多