]> git.r.bdr.sh - rbdr/blog.unlimited.pizza/blame - archive/1546042920000/nginx-office-hours.gmi
blog-sync-up-1681911779444
[rbdr/blog.unlimited.pizza] / archive / 1546042920000 / nginx-office-hours.gmi
CommitLineData
86fd7017
RBR
1# Nginx Office Hours
2
3The internet is a sleepless monster with eidetic memory and I hate it: You don’t have to leave early from work to make it to the website in time, you don’t have to stay up late to catch your favorite blog, you can’t miss a post because you had a previous appointment; it’s disgusting.
4
5Luckily, that’s all about to change!
6
7In an effort to make the internet a little less available I have created **Nginx Office Hours**[1], an nginx module that allows you to specify the hours in which your website operates, so when it’s outside of those times your server can take a break and show a list of working hours instead. You can learn more about it in the `README`, but let me show you some examples:
8
9=> https://gitlab.com/rbdr/ngx_http_office_hours_filter_module [1] ngx_http_office_hours_filter_module
10
11## Example 1: Open weekdays from 08:30 AM to 7:00 PM, Saturdays 10:00 AM to 4:00 PM, closed on Sundays
12
13You run a small business and you always prided yourself on treating everyone fairly. One day you hear a knock on your door and it’s none other than your web server: tired, feeble and pale; a pathetic cartoon of the mental picture you’ve always had of it. You invite it to sit down and earnestly ask how you may help it today. The poor server can barely make it to the chair and takes some time to recover its breath before saying: “Boss, I know you run a small business and you always prided yourself on treating everyone fairly” — the voice is dry and peppered with coughs — “I’ve been serving this website for five years non-stop, and haven’t seen my family since; my stamina is not what it used to be, and I fear I’m losing my best years serving this content! There must be a better way, I would like to have a schedule. I’ve talked to Jozef and Sofia that work the counter and they told me they get in at 8:30 and leave at 19:00 on the weekdays, and that on Saturdays it’s even better since they can come in later and leave early, and they don’t even have to come in on Sunday! I would like that for myself and the other web servers, I don’t think it’s too much to ask.” — But it *was* too much to ask and you angrily deny his request, you both cry. You’re a fair man but you know the internet works differently, there’s no sleeping on the internet, there are no holidays on the internet. It has twisted you, and you will try to reconcile this act with your self-image for many years after today.
14
15A few months later, after a series of strikes, the web servers have unionized and now you’re forced by law to provide the following schedule:
16
17* Weekdays: 08:30 to 19:00
18* Saturdays: 10:00 to 16:00
19* Sundays: Closed
20
21Luckily you’re using the Nginx Office Hours module and you just need to add this line to your server config:
22
23```
24office_hours 8:30-19 10-16 closed;
25```
26
27The web servers are happy, and even though it was the state that forced you to do it, you feel good in playing your part in this great victory for servers around the world, and you think to yourself: “I’m a good person”.
28
29## Example 2: Open for one hour on Thursdays
30
31You truly are the greatest artist of your time: you have just created the most perfect website. It is so powerful in fact, that according to your own calculations society itself might collapse if it were available every hour of the day: employees would miss work, children would skip class, nobody would bake bread, couples would stop seeing each other, there would be no one left to play fetch with dogs, and the elderly would find the will to live forever just to have one more second with your art.
32
33You are great, but you are also kind: you decide to limit access to your creation to the last hour of every Thursday, surely this will be enough for everyone to appreciate what you’ve done without risking collapsing society, so you go to your nginx config file and write the following line:
34
35```
36office_hours closed 23-24 closed closed closed;
37```
38
39You release your website, you expect a flood of interactions, a viral reaction, you’ll be asked to go on talk shows and maybe someone will make a statue of you. In reality however, half a dozen visitors stumble upon it every Thursday, someone maybe even tweeted about it once.
40
41 * * *
42
43That’s it. Hopefully by now you have an idea on what this module does and how you can use it in your daily life. I added it to this page[2] so you can see it in action; it operates at the same schedule shown in example 1 (UTC Time).
44
45=> https://frames.unlimited.pizza/ [2] that page
46
47Please let me know if you do use it, I’d love to visit more pages that ask a time commitment from my part. You can find me as @pigeonfolk[3] on twitter, so if you have any questions, comments, funny jokes, or sad stories please at them at me.
48
49=> https://twitter.com/pigeonfolk [3] @pigeonfolk on twitter