Skip to content

redirects: add arch-redirect cgi script

Kevin Morris requested to merge kevr/infrastructure:redirects into master

This script requires fcgiwrap

A simple CGI script used to redirect old git.archlinux.org
requests to their new home providers. This script requires hardcoded
mappings located in the global `mapping` variable (#L118). See the
variable for an explanatory comment about how it is constructed.

As far as hosting in `nginx` goes, one can copy this script
anywhere on the filesystem; let's use `arch-cgi-redirect` as an example.
The following configuration will provide straightforward
execution of this script via nginx to provide redirects.

First, install it somewhere:

    install -m 755 arch-git-redirect.py /path/to/arch-git-redirect

Then, you can configure nginx with the cgi path:

    server {
        listen 80;
        server_name localhost;

        location / {
            fastcgi_param REQUEST_URI $document_uri;
            fastcgi_param SCRIPT_FILENAME /path/to/arch-git-redirect;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
    }

When it's running, test it locally:

    curl -iI 'https://localhost/sprunge.git'

All URLs given without a repository found in it (repo.git) are
redirected to DEFAULT_LOCATION.

When a URL is given and a repository can be found, but no mapping
can be found, an error is printed to the user via 400 Bad Request.

Author: Kevin Morris <kevr@0cost.org>
License: MIT

Copyright (C) 2021 Arch Linux
All Rights Reserved.
Edited by Kevin Morris

Merge request reports