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
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.
7 => https://git.r.bdr.sh/rbdr/ngx_http_office_hours_filter_module ⧇ source
8 => https://git.sr.ht/~rbdr/ngx_http_office_hours_filter_module ⧉ mirror
14 You can install it from source:
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:
21 ./configure --add-dynamic-module=/path/to/ngx_http_office_hours_filter_module
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
28 ## The office_hours directive
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.
32 The first range will be used as the default value, and the rest will be read from right to left, starting with sunday.
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]
36 => /closed.html [2] A page that is never open.
38 ### Example 1: Open 24 hours
40 Don't use this directive.
42 ### Example 2: Open every day from 08:30 AM to 7:00 PM
50 ### Example 3: Open monday to saturday from 08:30 AM to 7:00 PM, but closed sundays
54 office_hours 8:30-19 closed;
58 ### Example 4: Open weekdays from 08:30 AM to 7:00 PM, Saturdays 10:00 AM to 4:00 PM, closed on sundays
62 office_hours 8:30-19 10-16 closed;
66 ### Example 5: Open weekdays from 08:30 AM to 7:00 PM, closed on thursdays, reduced hours on weekends.
70 office_hours 8:30-19 closed 8:30-19 10-16 10-16;
74 ### Example 6: Closed every day.
78 ## The office_hours_additional_information directive
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.
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>"