Package: goto-http-redirect-server
Go To HTTP Redirect ServerThe"Go To" HTTP Redirect Serverfor sharing dynamic shortcut URLs
on your network.Trivial to install and run.  Only uses Python built-in modules.  Super handy 😄 ‼Go To HTTP Redirect ServerInstall ManuallyInstall systemd ServiceUseGotchasLive ReloadReload via SignalsReload automatically using signals andgoto-http-redirect-server-inotify.shReload via browsersystemd ServicePro Tips--helpmessageInstall Manuallycreate a tab-separated values file ('\t') with a list of HTTP redirects.Fields are "from path", "to URL", "added by user", and "added on datetime".For example, given a file./redirects1.csv/bug	https://bugtracker.megacorp.local/view.cgi=${query}	alice	2019-08-10 00:05:10
/hr	http://human-resources.megacorp.local/login	bob	2018-07-11 22:15:10
/aws	https://us-west-2.console.aws.amazon.com/console/home?region=us-west-2#	carl	2019-01-05 12:35:10Install (pick one)pip install official release from pypi.orgpip install goto-http-redirect-serverpip install latest code from githubpip install "https://github.com/jtmoon79/goto_http_redirect_server/archive/master.zip"Download from github and runcurl "https://raw.githubusercontent.com/jtmoon79/goto_http_redirect_server/master/goto_http_redirect_server/goto_http_redirect_server.py"
python goto_http_redirect_server.py --versionusepip-runpip-run --use-pep517 --quiet "git+https://github.com/jtmoon79/goto_http_redirect_server" -- \
    -m goto_http_redirect_server --versionBuild and install using helper scriptstools/build-install.shortools/build-install.ps1git clone "https://github.com/jtmoon79/goto_http_redirect_server.git"
goto_http_redirect_server/tools/build-install.shBuild and installgit clone "https://github.com/jtmoon79/goto_http_redirect_server.git"
cd goto_http_redirect_server
python setup.py bdist_wheel
python -m pip install --user ./dist/goto_http_redirect_server-*-py3-none-any.whlstart theGo To HTTP Redirect Servergoto_http_redirect_server --redirects ./redirects1.csvor run as a modulepython -m goto_http_redirect_server --redirects ./redirects1.csvRequires at least Python version 3.6.Install systemd ServiceSeeservice/README.md.UseFrom your browser, browse to a redirect path!  For example, given a network hostgotorunninggoto_http_redirect_serveron port80, and given the
example redirects file./redirects1.csvabove, thenin your browser, typegoto/hr⏎. Your browser will end up athttp://human-resources.megacorp.local/login😆‼Trygoto/bug?456⏎… shows bug 456 😝❗❗GotchasSome browsers will assume a single word host, e.g.goto/hr, is a
search engine query, i.e. the browser will query Google for "goto/hr".
Type in a prepended http protocol, e.g.http://goto/hr⏎.**In most corporate networks, a user's workstation will DNS search the corporate
domain, e.g..local.  This allows users to enter browser URLgoto/hrwhich will resolve to hostgoto.local. Sometimes workstations
do not search the corporate domain due to DNS Search Order setting not
including.local. In that case, the user must specify the domain, e.g.
instead of typinggoto/hr⏎, the user must typegoto.local/hr⏎.****Mileage May Vary😔Live ReloadWhen the tab-separated values files are modified, this program can reload them.
No service downtime!Reload via SignalsNote during startup the Process ID (or query the host System).Send the process signal to the runninggoto_http_redirect_server.In Unix, usekill.In Windows, usewindows-kill.exeThe runninggoto_http_redirect_serverwill re-read all files passed via--redirects.Reload automatically using signals andgoto-http-redirect-server-inotify.shOn Linux, run the scriptgoto-http-redirect-server-inotify.shsetting variables as needed.
This script needs some work, but it functions.Reload via browserPass--reload-path /reloadas a program command-line options.Browse tohttp://host/reload.systemd ServiceSeeservice/directory for systemd service files.Pro TipsAdd a DNS addressable host on your network namedgoto. Rungoto_http_redirect_serveron the host.Network users can type in their browser address bargoto/…⏎to easily use
the"Go To" HTTP Redirect Server.**There are many methods to secure a running process.
One method is to useauthbindto rungoto_http_redirect_serveras a low
privilege process.apt install authbind
touch /etc/authbind/byport/80
chown nobody /etc/authbind/byport/80
chmod 0500 /etc/authbind/byport/80
sudo -u nobody -- authbind --deep python goto_http_redirect_server …This is an optional setting inthe systemd service.--helpmessageusage: goto_http_redirect_server [--redirects REDIRECTS_FILES] [--from-to from to] [--ip IP]
                                 [--port PORT] [--status-path STATUS_PATH]
                                 [--reload-path RELOAD_PATH] [--redirect-code REDIRECT_CODE]
                                 [--field-delimiter FIELD_DELIMITER]
                                 [--status-note-file STATUS_NOTE_FILE] [--no-cache]
                                 [--shutdown SHUTDOWN] [--log LOG] [--debug] [--version] [-?]

The "Go To" HTTP Redirect Server for sharing dynamic shortcut URLs on your network.

HTTP 307 Temporary Redirect reply server. Load this server with redirects of "from path" and
"to URL" and let it run indefinitely. Reload the running server by signaling the
process or HTTP requesting the RELOAD_PATH.

Redirects:
  One or more required. May be passed multiple times.

  --redirects REDIRECTS_FILES
                        File of redirects. Within a file, is one redirect entry per line. A
                        redirect entry is four fields: "from path", "to URL", "added by user", and
                        "added on datetime" separated by the FIELD_DELIMITER character.
  --from-to from to     A single redirect entry of "from path" and "to URL" fields. For example,
                        --from-to "/hr" "http://human-resources.megacorp.local/login"

Network Options:
  --ip IP, -i IP        IP interface to listen on. Default is 0.0.0.0 .
  --port PORT, -p PORT  IP port to listen on. Default is 80 .

Server Options:
  --status-path STATUS_PATH
                        The status path dumps information about the process and loaded redirects.
                        Default status page path is "/status".
  --reload-path RELOAD_PATH
                        Allow reloads by HTTP GET Request to passed URL Path. e.g. --reload-path
                        "/reload". May be a potential security or stability issue. The program will
                        always allow reload by process signal. Default is off.
  --redirect-code REDIRECT_CODE
                        Set HTTP Redirect Status Code as an integer. Most often the desired
                        override will be 307 (Temporary Redirect). Keep in mind, Status Code
                        Permanent Redirect will cause most browsers to cache the redirect. Any HTTP
                        Status Code could be used but odd things will happen if a value like 500 is
                        returned. This Status Code is only returned when a loaded redirect entry is
                        found and returned. Default successful redirect Status Code is 307
                        (Temporary Redirect).
  --field-delimiter FIELD_DELIMITER
                        Field delimiter string for --redirects files per-line redirect entries.
                        Default is "\t" (ordinal 9).
  --status-note-file STATUS_NOTE_FILE
                        Status page note: Filesystem path to a file with HTML that will be embedded
                        within a <div> element in the status page.
  --no-cache            Turn off caching. Caching will store finalized 'To:' Header URLs in process
                        memory. If users are expected to pass secrets (e.g. a password in a URL
                        parameter) then turn off caching.
  --shutdown SHUTDOWN   Shutdown the server after passed seconds. Intended for testing.
  --log LOG             Log to file at path LOG. Default logging is to sys.stderr.
  --debug               Set logging level to DEBUG. Default logging level is INFO.
  --version             Print "goto_http_redirect_server 1.2.1" and exit.
  -?, -h, --help        Print this help message and exit.

About Redirect Entries:

  Entries found in --redirects file(s) and entries passed via --from-to are
  combined.
  Entries passed via --from-to override any matching "from path" entry found in
  redirects files.
  The "from path" field corresponds to the URI Path in the originating request.
  The "to URL" field corresponds to HTTP Header "Location" in the server
  Redirect reply.

  A redirects file entry has four fields separated by FIELD_DELIMITER character:
  "from path", "to URL", "added by user", "added on datetime".
  For example,

    /hr http://human-resources.megacorp.local/login     bob     2019-09-07 12:00:00

  The last two fields, "added by user" and "added on datetime", are intended
  for record-keeping within an organization.

  A passed redirect should have a leading "/" as this is the URI path given for
  processing.
  For example, the URL "http://host/hr" is processed as URI path "/hr".

  A redirect will combine the various incoming URI parts.
  For example, given redirect entry:

    /b  http://bug-tracker.megacorp.local/view.cgi      bob     2019-09-07 12:00:00

  And incoming GET or HEAD request:

    http://goto/b?id=123

  will result in a redirect URL:

    http://bug-tracker.megacorp.local/view.cgi?id=123

Redirect Entry Template Syntax ("dynamic" URLs):

  Special substrings with Python string.Template syntax may be set in the
  redirect entry "To" field.

  First, given the URL

     http://host.com/pa/th;parm?a=A&b=B#frag

  the URI parts that form a urllib.urlparse ParseResult class would be:

    ParseResult(scheme='http', netloc='host.com', path='/pa/th',
                params='parm', query='a=A&b=B', fragment='frag')

  So then given redirect entry:

    /b  http://bug-tracker.megacorp.local/view.cgi?id=${query}  bob     2019-09-07 12:00:00

  and the incoming GET or HEAD request:

    http://goto/b?123

  Substring '123' is the 'query' part of the ParseResult. The resultant redirect
  URL would become:

    http://bug-tracker.megacorp.local/view.cgi?id=123

Redirect Entry Required Request Modifiers:

  Ending the Redirect Entry "from path" field with various URI separators allows
  preferences for which Redirect Entry to use. The purpose is to allow
  preferring a different Redirect Entry depending upon the users request.

  Given redirect entries:

    /b? http://bug-tracker.megacorp.local/view.cgi?id=${query}  bob     2019-09-07 12:00:00
    /b  http://bug-tracker.megacorp.local/main  bob     2019-09-07 12:00:00

  and the incoming GET or HEAD request:

    http://goto/b?123

  This will choose the first Redirect Entry and return 'Location' header

    http://bug-tracker.megacorp.local/view.cgi?id=123

  Whereas the incoming GET or HEAD request:

    http://goto/b

  This will choose the second Redirect Entry and return 'Location' header

    http://bug-tracker.megacorp.local/main

  The example combination sends a basic request for '/b' to some static page and
  a particular query request '/b?123' to a particular query path.
  Failed matches will "fallback" to the basic Redirect Entry, e.g. the Entry
  without any Required Request Modifiers.

  A Redirect Entry with Required Request Modifier will not match a request
  without such a modifier.

  Given redirect entries:

    /b? http://bug-tracker.megacorp.local/view.cgi?id=${query}  bob     2019-09-07 12:00:00

  and the incoming GET or HEAD request:

    http://goto/b

  will return 404 NOT FOUND.

  Required Request Modifiers must be at the end of the "from path" field string.
  Required Request Modifiers strings are:

     ';'  for user requests with a parameter.
     '?'  for user requests with a query.
     ';?' for user requests with a parameter and a query.

About Redirect Files:

   A line with a leading "#" will be ignored.

About Reloads:

  Sending a process signal to the running process will cause
  a reload of any files passed via --redirects.  This allows live updating of
  redirect information without disrupting the running server process.
  On Unix, the signal is SIGUSR1.  On Windows, the signal is SIGBREAK.
  On this system, the signal is Signals.SIGUSR1 (10).
  On Unix, use program `kill`.  On Windows, use program `windows-kill.exe`.

  A reload of redirect files may also be requested via passed URL path
  RELOAD_PATH.

About Paths:

  Options --status-path and --reload-path may be passed paths to obscure access
  from unauthorized users. e.g.

      --status-path '/62aa687a-c75d-47a5-b76f-4e33ea776e4b'

About this program:

  Underlying caching is so HTTP Redirect responses are a little bit faster.

  Modules used are available within the standard CPython distribution.
  Written for Python 3.7 but hacked to run with at least Python 3.6.This project is released underan MIT License granted by Dell Incorporated's
Open Source Project program. All project contributions are entirely
reflective of the respective author(s) and not of Dell Inc.Some portions of Javascript code in this project are subject toa separate MIT License.