Add proxy cache for PyPI

Investigate using apache proxy caching for PyPI instead of a full
mirror. Make the /pypi path proxy directly to pypi.org upstream instead
of to the rackspace AFS mirror.

We have to use the substitute module (already enabled) to rewrite the
embedded links in the html content returned, because instead of relative
links to something under /pypi which get redirected, the CDN links are
direct.

Change-Id: Id68ff2914ba7fb588092cff113e8d1536f7d5a56
This commit is contained in:
Monty Taylor 2018-07-17 09:31:56 -05:00
parent f965153ab8
commit f1723017d6
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 14 additions and 2 deletions

View File

@ -163,8 +163,19 @@ LogFormat "%h %l %u %t \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-a
# pypi
CacheEnable disk "/pypi"
ProxyPass "/pypi/" "http://mirror.dfw.rax.openstack.org/pypi/" ttl=120 keepalive=On retry=0
ProxyPassReverse "/pypi/" "http://mirror.dfw.rax.openstack.org/pypi/"
ProxyPass "/pypi/" "https://pypi.org/" ttl=120 keepalive=On retry=0
ProxyPassReverse "/pypi/" "https://pypi.org/
# files.pythonhosted.org
CacheEnable disk "/pypifiles"
ProxyPass "/pypifiles/" "https://files.pythonhosted.org/" ttl=120 keepalive=On retry=0
ProxyPassReverse "/pypifiles/" "https://files.pythonhosted.org/"
# Rewrite the locations of the actual files
<Location /pypi>
SetOutputFilter SUBSTITUTE
Substitute "s|https://files.pythonhosted.org/|/pypifiles/|ni"
</Location>
# images.linuxcontainers.org
CacheEnable disk "/images.linuxcontainers"
@ -225,6 +236,7 @@ LogFormat "%h %l %u %t \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-a
CacheEnable disk "/alpine"
ProxyPass "/alpine/" "http://dl-cdn.alpinelinux.org/alpine/" ttl=120 keepalive=On retry=0
ProxyPassReverse "/alpine/" "http://dl-cdn.alpinelinux.org/alpine/
</VirtualHost>
<VirtualHost <%= @vhost_name %>:8081>