Override DOCTYPE in wheel cache autoindex

As of pip 22.0, its HTML parser no longer accepts any page which
doesn't start with the string "<!DOCTYPE html>" and, unfortunately,
Apache's mod_autoindex declares a very specific HTML 3.2 doctype
instead, causing pip to break any time our wheel cache is added to
its indices. The main index we generate has been updated with
https://review.opendev.org/826969 but we need this change to address
Apache's dynamically generated file lists for that site.

Configure Apache to supply a custom header file for file indices
within the /wheel/ subtree of our mirror vhosts, and alias it from
outside the docroot in order to reduce clutter of the top-level
directory index. Also instruct mod_autoindex to omit its own
document preamble which would otherwise include the original doctype
declaration. Note that this omits the header title and H1 level
headings from the resulting pages, but as these are only meant for
machine parsing anyway and not humans, it's a compromise to keep the
solution as simple and straightforward as possible.

Change-Id: Id71174954b13b80483256d37f773b781f4956c21
changes/74/826974/1
Jeremy Stanley 1 year ago
parent 9b32637608
commit e61f584dbc

@ -0,0 +1,2 @@
<!DOCTYPE html>
<html><body>

@ -105,6 +105,14 @@
group: root
mode: 0444
- name: Install wheel_header.html
copy:
src: wheel_header.html
dest: '{{ www_base }}'
owner: root
group: root
mode: 0444
- name: Apache proxy cache
file:
path: /var/cache/apache2/proxy

@ -36,6 +36,14 @@ ErrorLogFormat "[%{cu}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% , \
Require all granted
</Directory>
# Pip really doesn't like the DOCTYPE declaration for autoindexes
# https://github.com/pypa/pip/issues/10825
Alias /wheel/.header.html /var/www/wheel_header.html
<Directory /var/www/mirror/wheel>
IndexOptions +SuppressHTMLPreamble
HeaderName /wheel/.header.html
</Directory>
# Caching reverse proxy for things that don't make sense in AFS
#
# General cache rules

Loading…
Cancel
Save