msupply-foundation / conforma-server

Conforma application manager (IRIMS) back-end
GNU Affero General Public License v3.0
4 stars 1 forks source link

Maintenance mode for productions servers #1009

Open CarlosNZ opened 1 year ago

CarlosNZ commented 1 year ago

Ideally we need some way to put the server into a "maintenance" mode, which just shows the user a helpful "unavailable" page (rather than an nginx fail page) while we take the server offline for updates (snapshot or build).

The simplest solution is just to temporarily re-direct everything to a simple HTML page that says "Server is currently offline for maintenance". However, there are other considerations:

Proposed solution

We use nginx to re-direct according to certain rules, and we dynamically change and reload the nginx config file according to which "mode" we're in:

Modes

This means that Nginx and the Conforma instances need to share the same private key for JWT signing/validation. This should be straightforward -- we store the key in the host system somewhere, and pass it into Conforma via environment vars.

How to switch "Modes"

A shell script to update nginx config and reload. We could add the "offline" and "online" modes to the existing conforma launch scripts, and then run commands to change to "Admin" mode and back.

CarlosNZ commented 7 months ago
  • Nginx authenticates using JWT. If isAdmin token, pass traffic through as normal. But if anything else, re-direct to maintenance page

Just realised that this is only available for nginx PLUS (paid) :(