From 981874fde01eaa8d8b251d7ab8ccfffecd7e1d13 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 28 Jan 2017 19:17:15 +0100 Subject: [PATCH] add manpages vhost extra info --- .../vhost/manpages.debian.org.erb | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 modules/roles/templates/static-mirroring/vhost/manpages.debian.org.erb diff --git a/modules/roles/templates/static-mirroring/vhost/manpages.debian.org.erb b/modules/roles/templates/static-mirroring/vhost/manpages.debian.org.erb new file mode 100644 index 000000000..b553829d5 --- /dev/null +++ b/modules/roles/templates/static-mirroring/vhost/manpages.debian.org.erb @@ -0,0 +1,100 @@ + + RequestHeader set Accept-Encoding "expr=gzip,%{req:Accept-Encoding}" early + AddDefaultCharset utf-8 + + # Replace e.g. pt-BR with pt_BR. + RequestHeader edit Accept-Language "-" "_" early + + # Only SetEnvIf gets called _before_ RewriteRule. + SetEnvIf Accept-Language "^(.*)$" ACCLANG=$1 INITIAL=t + SetEnvIf Accept-Language "^$" ACCLANG=en INITIAL=t + + RewriteEngine on + RewriteMap manpagesall dbm:/srv/manpages.debian.org/www/rwmap.dbm + RewriteMap lc int:tolower + + # URLs which end in a slash do not need to be rewritten + RewriteRule /$ - [last] + + # Redirect old CGI paths, keeping at least the manpage (the other + # parameters are left out for simplicity). + RewriteCond %{QUERY_STRING} ^$ + RewriteRule ^/cgi-bin/man.cgi$ / [redirect=301,last] + RewriteCond %{QUERY_STRING} (?:.*(?:^|&))query=([^&]+) + RewriteRule ^/cgi-bin/man.cgi /%1 [redirect=307,qsdiscard,last] + + # legacy manpages.debian.org patterns + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/0/(.*$) /$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([0-9ln]p?m?)/(.*$) /$2.$1 + + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man0/(.*$) /$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man([0-9ln]p?m?)/(.*$) /$2.$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/([^/]+)/man0/(.*$) /$2.$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/([^/]+)/man([0-9ln]p?m?)/(.*$) /$3.$2.$1 + + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([a-z]*)/([^/]+)/0/(.*$) /$1/$3.$2 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([a-z]*)/([^/]+)/([0-9ln]p?m?)/(.*$) /$1/$4.$3.$2 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([a-z]*)/0/(.*$) /$1/$2 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([a-z]*)/([0-9ln]p?m?)/(.*$) /$1/$3.$2 + + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/0/(.*$) /$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/([0-9ln]p?m?)/(.*$) /$2.$1 + + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/([^/]+)/(.*$) /$2.$1 + RewriteCond "%{env:INITIAL}" "=t" + RewriteRule ^/man/(.*$) /$1 + + # chomp off the first language tag for use in the following rules + RewriteCond "%{env:ACCLANG}" "^([^,;]+)" + RewriteRule .* - [E=ACCTOK:%1] + + RewriteCond "${manpagesall:${lc:$1}.%{env:ACCTOK}}" "^(.+)$" + RewriteRule ^(.+)$ %1 [redirect=307,last] + + # Example Accept-Language header: + # en-US,en;q=0.8,de-CH;q=0.6,de;q=0.4 + + RewriteRule .* - [E=!INITIAL] + + # while ACCLANG is non-empty, repeat + RewriteCond "%{env:ACCLANG}" "^(?:[^,]+),(.+)" + RewriteRule .* - [E=ACCLANG:%1,N] + + # fallback: maybe the language is already present? + RewriteCond "${manpagesall:${lc:$1}}" "^(.+)$" + RewriteRule ^(.+)$ %1 [redirect=307,last] + + + ExpiresActive On + ExpiresDefault "access plus 1 hours" + + + Require all denied + + + # To set the correct Content-Type (e.g. text/html). + RemoveType .gz + AddEncoding gzip gz + FilterDeclare gzip CONTENT_SET + FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip,.*gzip/" + FilterChain gzip + Options +Multiviews + + + ErrorDocument 404 https://dyn.manpages.debian.org%{REQUEST_URI}?%{QUERY_STRING} + + +# vim:ft=apache: -- 2.20.1