Merge "Serve pypi proxy cache from port 80"
This commit is contained in:
commit
02283b99c1
@ -38,17 +38,53 @@ LogFormat "%h %l %u %t \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-a
|
|||||||
</IfVersion>
|
</IfVersion>
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
RewriteEngine On
|
# Caching reverse proxy for things that don't make sense in AFS
|
||||||
|
#
|
||||||
|
# General cache rules
|
||||||
|
CacheRoot "/var/cache/apache2/proxy"
|
||||||
|
CacheDirLevels 5
|
||||||
|
CacheDirLength 2
|
||||||
|
# SSL support
|
||||||
|
SSLProxyEngine on
|
||||||
|
# Prevent thundering herds.
|
||||||
|
CacheLock on
|
||||||
|
CacheLockPath "/tmp/mod_cache-lock"
|
||||||
|
CacheLockMaxAge 5
|
||||||
|
# 5GiB
|
||||||
|
CacheMaxFileSize 5368709120
|
||||||
|
CacheStoreExpired On
|
||||||
|
|
||||||
# Pypi's bandersnatch URL's are:
|
# Added Aug 2017 in an attempt to avoid occasional 502 errors (around
|
||||||
# /pypi/simple/index.html
|
# 0.05% of requests) of the type:
|
||||||
# /pypi/simple/a/a/(index.html)?
|
#
|
||||||
# /pypi/simple/a/a/a-etc.whl
|
# End of file found: ... AH01102: error reading status line from remote server ...
|
||||||
# /pypi/simple/a/abcd/(index.html)?
|
#
|
||||||
# /pypi/simple/a/abcd/abcd-etc.whl
|
# Per [1]:
|
||||||
RewriteCond %{REQUEST_URI} ^/pypi/simple/([^/])([^/]*)
|
#
|
||||||
RewriteCond %{DOCUMENT_ROOT}/pypi/simple/$1/$1$2 -d
|
# This avoids the "proxy: error reading status line from remote
|
||||||
RewriteRule ^/pypi/simple/([^/])([^/]*)(/.*)?$ /pypi/simple/$1/$1$2$3 [L]
|
# server" error message caused by the race condition that the backend
|
||||||
|
# server closed the pooled connection after the connection check by the
|
||||||
|
# proxy and before data sent by the proxy reached the backend.
|
||||||
|
#
|
||||||
|
# [1] https://httpd.apache.org/docs/2.4/mod/mod_proxy_http.html
|
||||||
|
SetEnv proxy-initial-not-pooled 1
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
# pypi
|
||||||
|
CacheEnable disk "/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 INFLATE;SUBSTITUTE;DEFLATE
|
||||||
|
Substitute "s|https://files.pythonhosted.org/|/pypifiles/|ni"
|
||||||
|
</Location>
|
||||||
|
|
||||||
# Wheel URL's are:
|
# Wheel URL's are:
|
||||||
# /wheel/{distro}-{distro-version}/a/a/a-etc.whl
|
# /wheel/{distro}-{distro-version}/a/a/a-etc.whl
|
||||||
@ -58,29 +94,21 @@ LogFormat "%h %l %u %t \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-a
|
|||||||
RewriteCond %{DOCUMENT_ROOT}/wheel/$1/$2/$2$3 -d
|
RewriteCond %{DOCUMENT_ROOT}/wheel/$1/$2/$2$3 -d
|
||||||
RewriteRule ^/wheel/([^/]+)/([^/])([^/]*)(/.*)?$ /wheel/$1/$2/$2$3$4 [L]
|
RewriteRule ^/wheel/([^/]+)/([^/])([^/]*)(/.*)?$ /wheel/$1/$2/$2$3$4 [L]
|
||||||
|
|
||||||
# TODO(jhesketh): Remove this after bandersnatch implements pep503
|
|
||||||
# https://bitbucket.org/pypa/bandersnatch/pull-requests/20/fully-implement-pep-503-normalization/diff
|
|
||||||
|
|
||||||
# Special cases for openstack.nose_plugin & backports.*
|
# Special cases for openstack.nose_plugin & backports.*
|
||||||
|
RewriteCond %{REQUEST_URI} ^/wheel/
|
||||||
RewriteRule ^(.*)/openstack-nose-plugin(.*)$ $1/openstack.nose_plugin$2
|
RewriteRule ^(.*)/openstack-nose-plugin(.*)$ $1/openstack.nose_plugin$2
|
||||||
|
RewriteCond %{REQUEST_URI} ^/wheel/
|
||||||
RewriteRule ^(.*)/backports-(.*)$ $1/backports.$2
|
RewriteRule ^(.*)/backports-(.*)$ $1/backports.$2
|
||||||
|
|
||||||
RewriteCond %{REQUEST_URI} ^/pypi/simple/([^/])([^/]*)
|
|
||||||
RewriteCond %{DOCUMENT_ROOT}/pypi/simple/$1/$1$2 -d
|
|
||||||
RewriteRule ^/pypi/simple/([^/])([^/]*)(/.*)?$ /pypi/simple/$1/$1$2$3 [L]
|
|
||||||
|
|
||||||
# Try again but replacing -'s with .'s
|
# Try again but replacing -'s with .'s
|
||||||
|
RewriteCond %{REQUEST_URI} ^/wheel/
|
||||||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
|
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
|
||||||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
|
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
|
||||||
RewriteRule (.*)-(.*) $1.$2 [N]
|
RewriteRule (.*)-(.*) $1.$2 [N]
|
||||||
|
|
||||||
RewriteCond %{REQUEST_URI} ^/pypi/simple/([^/])([^/]*)
|
|
||||||
RewriteCond %{DOCUMENT_ROOT}/pypi/simple/$1/$1$2 -d
|
|
||||||
RewriteRule ^/pypi/simple/([^/])([^/]*)(/.*)?$ /pypi/simple/$1/$1$2$3 [L]
|
|
||||||
|
|
||||||
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_error.log
|
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_error.log
|
||||||
LogLevel warn
|
LogLevel warn
|
||||||
CustomLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_access.log combined
|
CustomLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_access.log combined-cache
|
||||||
ServerSignature Off
|
ServerSignature Off
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user