I have just added an a really nice script that has made maintaining my website infinitely easier, what follows is a brief explanation of the role this script plays in maintaining this website as well as design decisions made during its conception.
First let me explain what exactly nginxd does, the idea is actually pretty simple, trivial if you will. In essence nginxd allows me to disable (as well as enable) certain sections of my website. This allows me to gracefully control what is shown to the public, and what is only available on my local network. Before I get into more details, let me first define a few terms,
- unit: An nginx config that maps a domain to another domain:port.
- dunit: Essentially the inverse of a unit, except it maps the domain to a specified error page.
The design decisions made during the writing of the script basically boils down to the concept of units and their inverses, dunits. When nginxd is run, it is normally given a unit on which to act (not a dunit), and each unit has an implicit dunit (kind of like how in the field ℝ, for each r∈ℝ, there exists an r' such that r*r'=1). Hence working with the unit is fine, as we can easily deduce the associated dunit. The script was also written in a very modular fashion, allowing for reuse of functions multiple times over. This allowed for easy debugging.
So with the above in mind, what nginxd does is it when we want to enable a service (e.g git), we enable that service's unit whilst removing the associated dunit. This essentially exposes the service to the internet, and users can interact with it. When we wish to disable a service the inverse happens, that is, we enable that service's dunit whilst removing the associated unit, thus when we try reach the service from the internet we are served with an appropriate page stating that the service is currently down.
With the above explained, followed is a short example of how nginxd is used.
$ nginxd -e <unit>
$ nginxd -d <unit>
By default if run without any arguments, nginxd will enable all available units, this is the same as running:
$ nginxd -e all
Disable all units:
$ nginxd -d all
For help, simply run:
$ nginxd -h
nginxd comes with the following units (and each has its own dunit),
All in all, I must say this is a very useful script I have now added to my toolbox, making the maintaining of skiqqy.xyz a lot easier, Ironically just when I finished the script I made a post about it on mastadon, and after the post I accidentally broke the container running this blog, so I had to disable the blog for a bit to allow me to fix it. Once fixed I simply re-enabled the blog unit and my blog was up again. During the down time a few people actually got served the down page, which was the intended outcome.
That about wraps up this blog, I might delve a bit further into my plans for nginxd in another post at another time.