]> git.r.bdr.sh - rbdr/r.bdr.sh/blob - nginx_office_hours.gmi
Add bookmarks
[rbdr/r.bdr.sh] / nginx_office_hours.gmi
1 --- title: /nginx_office_hours.html
2 --- description: A victory for the server's labor rights: An nginx module that allows you to serve your content only during the server's office hours.
3 ## NGINX Office Hours Module
4
5 Or ngx_http_office_hours_filter_module for short, it's a module for nginx that lets you specify a schedule and only serve content during that time.
6
7 => https://git.r.bdr.sh/rbdr/ngx_http_office_hours_filter_module view source @ git.r.bdr.sh
8 => https://git.sr.ht/~rbdr/ngx_http_office_hours_filter_module source mirror @ sourcehut
9
10 ## Install
11
12 ### From Source
13
14 You can install it from source:
15
16 1. Clone nginx source to a directory
17 2. Clone ngx_http_office_hours_filter_module to another directory
18 3. Build NGINX as you usually would[1], appending the option for this dynamic module:
19
20 ```
21 ./configure --add-dynamic-module=/path/to/ngx_http_office_hours_filter_module
22 make
23 sudo make install
24 ```
25
26 => https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#compiling-and-installing-from-source [1] Compiling And Installing NGINX from Source
27
28 ## The office_hours directive
29
30 The office_hours directive expects a list of time ranges separated by spaces in the format: "HH:mm-HH:mm". The hours should be in 24 hour format, and the minutes are optional. The word "closed" can be used to indicate that the server is not operating on that day.
31
32 The first range will be used as the default value, and the rest will be read from right to left, starting with sunday.
33
34 When the current time is within those hours, the server will operate as usual, otherwise it will return a 403 with a page showing the operating hours of the service. See this example for a page that's always closed[2]
35
36 => /closed.html [2] A page that is never open.
37
38 ### Example 1: Open 24 hours
39
40 Don't use this directive.
41
42 ### Example 2: Open every day from 08:30 AM to 7:00 PM
43
44 ```
45 location / {
46 office_hours 8:30-19;
47 }
48 ```
49
50 ### Example 3: Open monday to saturday from 08:30 AM to 7:00 PM, but closed sundays
51
52 ```
53 location / {
54 office_hours 8:30-19 closed;
55 }
56 ```
57
58 ### Example 4: Open weekdays from 08:30 AM to 7:00 PM, Saturdays 10:00 AM to 4:00 PM, closed on sundays
59
60 ```
61 location / {
62 office_hours 8:30-19 10-16 closed;
63 }
64 ```
65
66 ### Example 5: Open weekdays from 08:30 AM to 7:00 PM, closed on thursdays, reduced hours on weekends.
67
68 ```
69 location / {
70 office_hours 8:30-19 closed 8:30-19 10-16 10-16;
71 }
72 ```
73
74 ### Example 6: Closed every day.
75
76 Uninstall nginx.
77
78 ## The office_hours_additional_information directive
79
80 With this directive you can specify additional information for when the server is closed, such as contact information or alternate locations for the data. It accepts a text containing HTML that will be injected to the body of the office hours page.
81
82 ```
83 location / {
84 office_hours_additional_information "<h1>Additional Information></h1>
85 <p>Please do not email us asking to open the website 24/7. Send all complaints to friendship.quest/@ruben</p>"
86 }
87 ```