]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/immae/production.nix
439b455171f3b9bae2bdb95fc21306e8f52943f4
[perso/Immae/Config/Nix.git] / modules / private / websites / immae / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.immae.production;
4 varDir = "/var/lib/buildbot/outputs/immae/blog";
5 coursDir = "/var/lib/buildbot/outputs/immae/cours";
6 rechercheDir = "/var/lib/buildbot/outputs/immae/recherche";
7 recettesDir = "/var/lib/buildbot/outputs/immae/recettes";
8 historyDir = "/var/lib/buildbot/outputs/immae/history";
9 env = config.myEnv.websites.immae;
10 in {
11 options.myServices.websites.immae.production.enable = lib.mkEnableOption "enable Immae's website";
12
13 config = lib.mkIf cfg.enable {
14 services.webstats.sites = [ { name = "www.immae.eu"; } ];
15
16 services.websites.env.production.vhostConfs.immae_production = {
17 certName = "immae";
18 addToCerts = true;
19 certMainHost = "www.immae.eu";
20 hosts = [ "www.immae.eu" "immae.eu" ];
21 root = varDir;
22 extraConfig = [
23 ''
24 Use Stats www.immae.eu
25 Header always set Strict-Transport-Security "max-age=31536000"
26
27 <LocationMatch /.well-known/(webfinger|host-meta)>
28 Header always set Referrer-Policy "strict-origin-when-cross-origin"
29 RequestHeader set X-Forwarded-Proto "https"
30
31 RewriteRule ^(.*)$ https://mastodon.immae.eu%{REQUEST_URI} [QSA,L]
32 </LocationMatch>
33
34 RewriteEngine On
35 RewriteCond "%{REQUEST_URI}" "!^/.well-known/(webfinger|host-meta)"
36 RewriteCond "%{HTTP_HOST}" "!^www\.immae\.eu$" [NC]
37 RewriteRule ^(.+)$ https://www.immae.eu$1 [R=302,L]
38
39 <Directory ${varDir}>
40 DirectoryIndex index.htm index.html
41 Options Indexes FollowSymLinks MultiViews Includes
42 AllowOverride All
43 Require all granted
44 </Directory>
45
46 Alias /.well-known/chatonsinfos ${./chatons}
47 <Directory ${./chatons}>
48 Options Indexes FollowSymLinks MultiViews Includes
49 AllowOverride None
50 Require all granted
51 </Directory>
52
53 Alias /cours ${coursDir}
54 <Directory ${coursDir}>
55 DirectoryIndex index.htm index.html
56 Options Indexes FollowSymLinks MultiViews Includes
57 AllowOverride All
58 Require all granted
59 </Directory>
60
61 Alias /eurl ${./eurl}
62 <Directory ${./eurl}>
63 DirectoryIndex index.htm index.html
64 Options Indexes FollowSymLinks MultiViews Includes
65 AllowOverride None
66 Require all granted
67 </Directory>
68
69 Alias /recherche ${rechercheDir}
70 <Directory ${rechercheDir}>
71 DirectoryIndex index.htm index.html
72 Options Indexes FollowSymLinks MultiViews Includes
73 AllowOverride All
74 Require all granted
75 </Directory>
76
77 Alias /recettes ${recettesDir}
78 <Directory ${recettesDir}>
79 DirectoryIndex index.htm index.html
80 Options Indexes FollowSymLinks MultiViews Includes
81 AllowOverride All
82 Require all granted
83 </Directory>
84
85 Alias /history ${historyDir}
86 <Directory ${historyDir}>
87 DirectoryIndex index.html
88 AllowOverride None
89 Require all granted
90 </Directory>
91 ''
92 ];
93 };
94
95 services.websites.env.production.vhostConfs.immae_fr = {
96 certName = "immae";
97 addToCerts = true;
98 hosts = [ "www.immae.fr" "immae.fr" ];
99 root = null;
100 extraConfig = [ ''
101 RedirectMatch 301 ^/((?!\.well-known.*$).*)$ https://www.immae.eu/chapeaux/
102 '' ];
103 };
104
105 services.websites.env.production.vhostConfs.immae_bouya = {
106 certName = "immae";
107 addToCerts = true;
108 hosts = [ "bouya.org" "www.bouya.org" ];
109 root = rechercheDir;
110 extraConfig = [ ''
111 <Directory ${rechercheDir}>
112 DirectoryIndex index.htm index.html
113 Options Indexes FollowSymLinks MultiViews Includes
114 AllowOverride All
115 Require all granted
116 </Directory>
117 '' ];
118 };
119 };
120 }