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 | '("add_header Strict-Transport-Security \"max-age=31536000; includeSubDomains\" always;" |
58 | "add_header X-Frame-Options DENY;" |
59 | "add_header X-Content-Type-Options nosniff;" |
60 | "add_header Content-Security-Policy 'default-src \\'none\\'; img-src \\'self\\'; style-src \\'self\\' \\'unsafe-inline\\'; frame-ancestors \\'none\\'';" |
61 | "add_header Referrer-Policy no-referrer;" |
62 | "set $first_language $http_accept_language;" |
63 | "if ($http_accept_language ~* '(en|eo|fr)') {" |
64 | " set $first_language $1;" |
65 | "}" |
66 | "set $language_suffix $first_language;" |
67 | "if ($cookie_language) {" |
68 | " set $language_suffix $cookie_language;" |
69 | "}" |
70 | "if ($uri ~ \\.en.html$) {" |
71 | " set $language_suffix 'en';" |
72 | "}" |
73 | "if ($uri ~ \\.eo.html$) {" |
74 | " set $language_suffix 'eo';" |
75 | "}" |
76 | "if ($uri ~ \\.fr.html$) {" |
77 | " set $language_suffix 'fr';" |
78 | "}" |
79 | "if ($uri ~ (.*).html) {" |
80 | " set $my_uri $1.$language_suffix.html;" |
81 | "}" |
82 | "location ~ \\.html$ {" |
83 | " add_header Set-Cookie 'language=$language_suffix;HttpOnly;Secure';" |
84 | " add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';" |
85 | " add_header Strict-Transport-Security \"max-age=31536000; includeSubDomains\" always;" |
86 | " add_header X-Frame-Options DENY;" |
87 | " add_header X-Content-Type-Options nosniff;" |
88 | " add_header Content-Security-Policy 'default-src \\'none\\'; img-src \\'self\\'; style-src \\'self\\' \\'unsafe-inline\\'; frame-ancestors \\'none\\'';" |
89 | " add_header Referrer-Policy no-referrer;" |
90 | " expires off;" |
91 | " try_files $my_uri $uri $uri/ =404;" |
92 | "}" |
93 | "error_page 404 /404;"))))) |
94 | (simple-service 'default-http-server nginx-service-type |
95 | (list (nginx-server-configuration |
96 | (ssl-certificate "/etc/letsencrypt/live/lepiller.eu/fullchain.pem") |
97 | (ssl-certificate-key "/etc/letsencrypt/live/lepiller.eu/privkey.pem") |
98 | (listen '("443 ssl http2" "[::]:443 ssl http2")) |
99 | (server-name '(default))(root "/srv/http/default"))))) |
100 | (lepiller-mail-services |
101 | #:interface "ens18" |
102 | #:domain "lepiller.eu") |
103 | (server-services "hermes")))) |
104 |