aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/tools
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-02-13 13:05:40 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-02-13 13:05:40 +0100
commitea9c6fe8041faab128391a0c03ec3bde25e29fa3 (patch)
tree065d038b07b39c031139830378f3d55224096648 /modules/private/websites/tools
parent8a304ef46e1ad221253f883a8a296a12018e3d30 (diff)
downloadNix-ea9c6fe8041faab128391a0c03ec3bde25e29fa3.tar.gz
Nix-ea9c6fe8041faab128391a0c03ec3bde25e29fa3.tar.zst
Nix-ea9c6fe8041faab128391a0c03ec3bde25e29fa3.zip
Add Tinc VPN
Diffstat (limited to 'modules/private/websites/tools')
-rw-r--r--modules/private/websites/tools/tools/default.nix3
-rw-r--r--modules/private/websites/tools/vpn/default.nix15
-rw-r--r--modules/private/websites/tools/vpn/www/index.html91
-rw-r--r--modules/private/websites/tools/vpn/www/style.css61
4 files changed, 170 insertions, 0 deletions
diff --git a/modules/private/websites/tools/tools/default.nix b/modules/private/websites/tools/tools/default.nix
index f88cf06..9fb2d03 100644
--- a/modules/private/websites/tools/tools/default.nix
+++ b/modules/private/websites/tools/tools/default.nix
@@ -102,6 +102,7 @@ in {
102 root = "/var/lib/ftp/tools.immae.eu"; 102 root = "/var/lib/ftp/tools.immae.eu";
103 extraConfig = [ 103 extraConfig = [
104 '' 104 ''
105 RedirectMatch 301 ^/vpn(.*)$ https://vpn.immae.eu$1
105 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1 106 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1
106 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse 107 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse
107 108
@@ -152,6 +153,8 @@ in {
152 153
153 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse 154 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse
154 155
156 RedirectMatch 301 ^/vpn(.*)$ https://vpn.immae.eu$1
157
155 RedirectMatch 301 ^/(.*)$ https://tools.immae.eu/$1 158 RedirectMatch 301 ^/(.*)$ https://tools.immae.eu/$1
156 '' 159 ''
157 ]; 160 ];
diff --git a/modules/private/websites/tools/vpn/default.nix b/modules/private/websites/tools/vpn/default.nix
new file mode 100644
index 0000000..cfe010c
--- /dev/null
+++ b/modules/private/websites/tools/vpn/default.nix
@@ -0,0 +1,15 @@
1{ lib, pkgs, config, ... }:
2let
3 cfg = config.myServices.vpn;
4in {
5 config = lib.mkIf cfg.enable {
6 services.websites.env.tools.vhostConfs.vpn = {
7 certName = "eldiron";
8 addToCerts = true;
9 hosts = [ "vpn.immae.eu" ];
10 root = "/run/current-system/webapps/_vpn";
11 };
12
13 myServices.websites.webappDirs._vpn = ./www;
14 };
15}
diff --git a/modules/private/websites/tools/vpn/www/index.html b/modules/private/websites/tools/vpn/www/index.html
new file mode 100644
index 0000000..08199fb
--- /dev/null
+++ b/modules/private/websites/tools/vpn/www/index.html
@@ -0,0 +1,91 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>VPN configuration</title>
6 <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
7 <link rel="stylesheet" href="style.css" type="text/css" />
8 <meta name="viewport" content="width=device-width, initial-scale=1" />
9 </head>
10 <body>
11 <div class="instructions">
12 <h2>Installation</h2>
13 <ul>
14 <li>Installer tinc</li>
15 <li>Créer un fichier /etc/tinc/Immae/tinc.conf sur ce modèle, en remplaçant la ligne <code>A choisir</code> par un nom de la forme DomaineMachine. La machine sera accessible par <code>machine.domaine.immae.eu</code> par la suite
16 <pre>
17Name = A choisir
18Mode = switch
19Interface = vpn6
20ConnectTo = ImmaeEu
21
22# The tap device tinc will use.
23# Default is /dev/tap0 for ethertap or FreeBSD,
24# /dev/tun0 for Solaris and OpenBSD,
25# and /dev/net/tun for Linux tun/tap device.
26Device = /dev/net/tun
27LocalDiscovery = yes
28 </pre>
29 </li>
30 <li>Vérifier l'existence du device indiqué à la ligne "<code>Device</code>" dans le système.
31 <pre>ls /dev/net/tun</pre>
32 </li>
33 <li><em class="important">Si tinc tourne déjà, l'arrêter !!</em></li>
34 <li>Générer les clés&nbsp;:
35 <pre>tincd -K -n Immae</pre>
36 Stocker la clé privée dans <code>/etc/tinc/Immae/rsa_key.priv</code> et la clé publique dans un autre dossier<br />
37 (<em>pas <code>/etc/tinc/Immae/hosts/</code> comme proposé par défaut</em>).<br />
38 L'endroit importe peu, elle ne sera pas conservée.</li>
39 <li>M'envoyer le nom choisi dans <code>tinc.conf</code>, et la clé publique</li>
40 <li>Cloner le dépôt des hôtes du réseau
41 <pre>
42cd /etc/tinc/Immae
43git clone https://git.immae.eu/perso/Immae/Config/tinc/hosts
44 </pre>
45 </li>
46 <li>Une fois que j'ai confirmé avoir reçu la clé&nbsp;:
47 <pre>
48cd /etc/tinc/Immae/hosts
49git pull origin master
50 </pre>
51 </li>
52 <li>Uniquement pour Debian/Ubuntu: Ajouter <code>Immae</code> dans <code>/etc/tinc/nets.boot</code> (créer le fichier si nécessaire).</li>
53 <li>Selon le système, démarrer tinc&nbsp;:
54 <pre>
55/etc/init.d/tinc start
56 </pre>
57 ou
58 <pre>
59systemctl enable tincd@Immae.service
60systemctl start tincd@Immae.service
61 </pre>
62 </li>
63 </ul>
64
65 <h2>Choix d'ip</h2>
66 <ul>
67 <li>Choisir une ip : <code>2001:aaaa:b:cccc:d::xxxx:yyyy/96</code> (le préfixe <code>2001:aaaa:b:cccc:d</code> est imposé). Choix uniquement sur le <code>yyyy</code> (n'importe quel nombre entre <code>1</code> et <code>ffff</code>), le <code>xxxx</code> est dépendant du domaine</li>
68 <li>M'envoyer le choix de l'ip</li>
69
70 <li>Si on veut éviter de passer systématiquement par le serveur immae.eu (Par
71 défaut linux préfère l'ipv6 dès qu'il en a possibilité), modifier le fichier
72 <code>/etc/gai.conf</code>. Quelques lignes à décommenter, tout est déjà dans le fichier :
73 <pre>
74(...)
75#
76precedence ::1/128 50
77precedence ::/0 40
78precedence 2002::/16 30
79precedence ::/96 20
80#precedence ::ffff:0:0/96 10
81#
82# For sites which prefer IPv4 connections change the last line to
83#
84precedence ::ffff:0:0/96 100
85(...)
86 </pre>
87 </li>
88 </ul>
89 </div>
90 </body>
91</html>
diff --git a/modules/private/websites/tools/vpn/www/style.css b/modules/private/websites/tools/vpn/www/style.css
new file mode 100644
index 0000000..b177fec
--- /dev/null
+++ b/modules/private/websites/tools/vpn/www/style.css
@@ -0,0 +1,61 @@
1* {
2 margin:0;
3 padding:0;
4 -webkit-box-sizing:border-box;
5 -moz-box-sizing:border-box;
6 box-sizing: border-box;
7}
8
9html {
10 min-height:100%;
11 border-top:10px solid #ECEEF1;
12 border-bottom:10px solid #ECEEF1;
13 color:#61666c;
14 font-weight:400;
15 font-size:1em;
16 font-family:'Open Sans', sans-serif;
17 line-height:2em;
18}
19body {
20 padding:20px;
21 -webkit-backface-visibility:hidden;
22}
23code {
24 font-family:consolas,monospace;
25}
26a {
27 color:#61666c;
28 text-decoration:none;
29}
30a, img {
31 border:none;
32 outline:none
33}
34a:hover {
35 color:#2a2a2a;
36}
37
38.instructions {
39 margin:0 auto;
40 padding-top:20px;
41 max-width:80%;
42}
43
44.instructions a {
45 text-decoration: underline;
46}
47
48.instructions h2 {
49 margin-top: 10px;
50}
51.instructions em.important:before {
52 content: "⚠ Important ⚠ ";
53 color: red;
54}
55.instructions pre {
56 width: 50em;
57 padding: 10px 15px;
58 display: table;
59 border: 1px inset black;
60 line-height: 1em;
61}