hermes.scm
1 | ;;; Tyreunom's system administration and configuration tools. |
2 | ;;; |
3 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
4 | ;;; |
5 | ;;; This program is free software: you can redistribute it and/or modify |
6 | ;;; it under the terms of the GNU General Public License as published by |
7 | ;;; the Free Software Foundation, either version 3 of the License, or |
8 | ;;; (at your option) any later version. |
9 | ;;; |
10 | ;;; This program is distributed in the hope that it will be useful, |
11 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ;;; GNU General Public License for more details. |
14 | ;;; |
15 | ;;; You should have received a copy of the GNU General Public License |
16 | ;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | (use-modules (gnu)) |
19 | (use-modules (gnu system)) |
20 | (use-modules (gnu bootloader) (gnu bootloader grub)) |
21 | (use-modules (gnu services dns)) |
22 | (use-modules (gnu services web)) |
23 | (use-modules (config certbot) (config dns) (config mail) (config network) (config os)) |
24 | |
25 | (operating-system |
26 | (inherit (tyreunom-os "hermes")) |
27 | (bootloader |
28 | (bootloader-configuration |
29 | (target "/dev/sda") |
30 | (bootloader grub-bootloader))) |
31 | (file-systems (cons (file-system |
32 | (mount-point "/") |
33 | (device (uuid "27798665-5606-4fde-8da8-cc371e603892")) |
34 | (type "ext4")) |
35 | %base-file-systems)) |
36 | (services |
37 | (append |
38 | (list |
39 | hermes-network-service |
40 | (service nginx-service-type) |
41 | (service knot-service-type |
42 | (knot-configuration |
43 | (zones (list lepiller-master-zone |
44 | ipv4-reverse-master-zone |
45 | ipv6-reverse-master-zone)))) |
46 | (certbot-service `(("lepiller.eu" "www.lepiller.eu" "smtp.lepiller.eu"))) |
47 | (simple-service 'lepiller-http-server nginx-service-type |
48 | (list (nginx-server-configuration |
49 | (ssl-certificate "/etc/letsencrypt/live/lepiller.eu/fullchain.pem") |
50 | (ssl-certificate-key "/etc/letsencrypt/live/lepiller.eu/privkey.pem") |
51 | (listen '("443 ssl http2" "[::]:443 ssl http2")) |
52 | (server-name '("lepiller.eu" "www.lepiller.eu")) |
53 | (root "/srv/http/lepiller/site") |
54 | (index '("index.$language_suffix.html" "index.html")) |
55 | (try-files '("$uri.$language_suffix.html" "$uri" "$uri/" "=404")) |
56 | (raw-content |
57 | '("set $first_language $http_accept_language;" |
58 | "if ($http_accept_language ~* '(en|eo|fr)') {" |
59 | " set $first_language $1;" |
60 | "}" |
61 | "set $language_suffix $first_language;" |
62 | "if ($cookie_language) {" |
63 | " set $language_suffix $cookie_language;" |
64 | "}" |
65 | "if ($uri ~ \\.en.html$) {" |
66 | " set $language_suffix 'en';" |
67 | "}" |
68 | "if ($uri ~ \\.eo.html$) {" |
69 | " set $language_suffix 'eo';" |
70 | "}" |
71 | "if ($uri ~ \\.fr.html$) {" |
72 | " set $language_suffix 'fr';" |
73 | "}" |
74 | "if ($uri ~ (.*).html) {" |
75 | " set $my_uri $1.$language_suffix.html;" |
76 | "}" |
77 | "location ~ \\.html$ {" |
78 | " add_header Set-Cookie language=$language_suffix;" |
79 | " expires off;" |
80 | " add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';" |
81 | " try_files $my_uri $uri $uri/ =404;" |
82 | "}" |
83 | "error_page 404 /404;"))))) |
84 | (simple-service 'default-http-server nginx-service-type |
85 | (list (nginx-server-configuration |
86 | (ssl-certificate "/etc/letsencrypt/live/lepiller.eu/fullchain.pem") |
87 | (ssl-certificate-key "/etc/letsencrypt/live/lepiller.eu/privkey.pem") |
88 | (listen '("443 ssl http2" "[::]:443 ssl http2")) |
89 | (server-name '(default))(root "/srv/http/default"))))) |
90 | lepiller-mail-services |
91 | (server-services "hermes")))) |
92 |