1.0.7 • Published 3 years ago

rwserve-lowercase v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago
Open Source RWSERVE plugin

Lowercase

Probe file system for lowercase filename

Motivation

Filenames on Windows are case insensitive, so a request for Hello-World.html and hello-world.html are equivalent. Not so on Linux. These are recognized as two distinct files. Neither way is "right", but moving from one file system to another with names like this is problematic.

Because of this, it has become customary to restrict URL paths to be all lowercase. Websites that started out on a case insensitive file system and were later moved to a case-sensitive file system, may break when external hyperlinks point to the incorrectly cased filename. One solution is to rename all filenames to their lowercase equivalent, and use this plugin to instruct browsers of the change.

The algorithm is straightforward:

  1. Check the file system to see if the requested resource path exists; if so, skip the remaining steps and resume standard processing.
  2. Apply a lowercase filter to the full resource path and filename.
  3. Probe the file system to see if the lowercased version exists:

    • If so, return with 302 Found and a location header containing the correct resource path.
    • If not, return with 404 Not Found.

Customization

This plugin is open source and can be modified or enhanced to perform tasks such as these:

  • Safely reorganize the directory structure of your website, without unnecessarily breaking external links.
  • Define a lookup table with original filenames and archived filenames, where access to archived content is behind a paywall.

Download

The plugin module is available from NPM . Before proceeding, you should already have Node.js and RWSERVE configured and tested.

This module should be installed on your web server in a well-defined place, so that it can be discovered by RWSERVE. The standard place for public domain plugins is /srv/rwserve-plugins.

Configuration is Everything

Make the software available by declaring it in the plugins section of your configuration file. For detailed instructions on how to do this, refer to the plugins documentation on the Read Write Tools HTTP/2 Server website.

TL;DR

The sample router shown above will route all requests (*) for GET or HEAD methods, to the plugin.

Cookbook

A full configuration file with typical settings for a server running on localhost port 7443, is included in this NPM module at etc/lowercase-config. To use this configuration file, adjust these variables if they don't match your server setup:

Deployment

Once you've tested the plugin and are ready to go live, adjust your production web server's configuration in /etc/rwserve/rwserve.conf and restart it using systemd . . .

. . . then monitor its request/response activity with journald.

Prerequisites

This is a plugin for the Read Write Tools HTTP/2 Server, which works on Linux platforms.

Review

License

The rwserve-lowercase plugin is licensed under the MIT License.

Availability

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

6 years ago

1.0.2

6 years ago