Skip to content

Commit 308f647

Browse files
committedJul 30, 2021
New highdef.network splash site (clearnet & internal)
1 parent b11952e commit 308f647

12 files changed

+253
-0
lines changed
 

‎.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "dn42-registry"]
22
path = dn42-registry
33
url = git@git.dn42.dev:dn42/registry.git
4+
[submodule "roles/apps_nginx"]
5+
path = roles/apps_nginx
6+
url = https://github.com/jlu5/ansible-nginx

‎global-config/general.yml

+8
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,11 @@ ip6tables_rules_path: "{{ iptables_dir }}/rules.v6"
6464
automation_user: dn42-automation
6565
automation_root_dir: /opt/dn42
6666
automation_user_home: /opt/dn42/automation/
67+
68+
# splash hosts for clearnet
69+
splash_hosts:
70+
- highdef.network
71+
- www.highdef.network
72+
73+
letsencrypt_account_email: "{{ 'hel' + 'lo@jl' + 'u5.com' if ownas == '4242421080' | mandatory('Please change letsencrypt_account_email to your account') }}"
74+
letsencrypt_webroot_path: "/var/www/html"

‎hosts.yml

+5
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ staging:
399399
dn42-es-mad01.jlu5.com:
400400
dn42-it-mil01.jlu5.com:
401401

402+
# Clearnet web hosts
403+
web:
404+
hosts:
405+
dn42-us-sea02.jlu5.com:
406+
402407
# Extra hosts managed by Ansible but with a reduced set of services
403408
private:
404409
hosts:

‎roles/apps_nginx

Submodule apps_nginx added at 057e418
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Comfortaa&display=swap');
2+
3+
body {
4+
text-align: center;
5+
margin-top: 5%;
6+
background-color: #121214;
7+
8+
color: #dedede;
9+
font-family: sans-serif;
10+
font-size: large;
11+
}
12+
13+
body, html {
14+
width: 100%;
15+
height: 100%;
16+
overflow: hidden;
17+
}
18+
19+
.main {
20+
width: 80%;
21+
margin: auto;
22+
}
23+
24+
h1, h2 {
25+
font-family: 'Comfortaa', cursive;
26+
margin: 1vh;
27+
text-shadow: 2px 2px 10px #121240;
28+
}
29+
30+
h1 {
31+
font-size: 300%;
32+
}
33+
34+
h2 {
35+
font-size: 200%;
36+
}
37+
38+
a {
39+
color: lightblue;
40+
}
41+
a:hover {
42+
color: #cee7ef;
43+
}
44+
45+
a:visited {
46+
color: pink;
47+
}
48+
a:visited:hover {
49+
color: #ffd6dd;
50+
}
51+
52+
#serverinfo-container {
53+
max-width: 600px;
54+
margin: 0 auto;
55+
text-align: left;
56+
display: block;
57+
}
58+
59+
hr {
60+
margin-bottom: 3vh;
61+
}
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- name: Create splash page folder
2+
file:
3+
path: "{{ automation_root_dir }}/splash"
4+
state: directory
5+
6+
- name: Upload splash page files
7+
template:
8+
src: index-dn42.html.j2
9+
dest: "{{ automation_root_dir }}/splash/index-dn42.html"
10+
- name: Upload splash page files
11+
template:
12+
src: index-clearnet.html.j2
13+
dest: "{{ automation_root_dir }}/splash/index-clearnet.html"
14+
- name: Upload splash page files
15+
copy:
16+
src: style.css
17+
dest: "{{ automation_root_dir }}/splash/style.css"
18+
19+
- name: Setup splash page for dn42
20+
include_role:
21+
name: apps_nginx
22+
vars:
23+
nginx_site:
24+
src: dn42-splash.conf.j2
25+
dst: dn42-splash.conf
26+
27+
- name: Setup splash page for clearnet
28+
include_role:
29+
name: apps_nginx
30+
vars:
31+
letsencrypt_domains: "{{ splash_hosts }}"
32+
nginx_site:
33+
src: dn42-splash-clearnet.conf.j2
34+
dst: dn42-splash-clearnet.conf
35+
when: "'web' in group_names"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Clearnet (HTTP -> HTTPS redirect)
2+
server {
3+
listen 80;
4+
listen [::]:80;
5+
6+
{% for server_name in splash_hosts %}
7+
server_name {{ server_name }};
8+
{% endfor %}
9+
return 301 https://$server_name$request_uri;
10+
}
11+
12+
# Clearnet splash
13+
server {
14+
listen 443 ssl http2;
15+
listen [::]:443 ssl http2;
16+
17+
{% for server_name in splash_hosts %}
18+
server_name {{ server_name }};
19+
{% endfor %}
20+
21+
ssl_trusted_certificate /etc/letsencrypt/live/{{ splash_hosts[0] }}/chain.pem;
22+
ssl_certificate /etc/letsencrypt/live/{{ splash_hosts[0] }}/fullchain.pem;
23+
ssl_certificate_key /etc/letsencrypt/live/{{ splash_hosts[0] }}/privkey.pem;
24+
include snippets/nginx-ssl.conf;
25+
26+
location /.well-known {
27+
{# webroot for LE cert validation #}
28+
root /var/www/html;
29+
}
30+
31+
location / {
32+
root {{ automation_root_dir }}/splash;
33+
index index-clearnet.html;
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{% set rtrname = dns_auto_host_record_format | replace("%s", shortname) %}
2+
3+
# dn42 splash
4+
server {
5+
listen 80;
6+
listen [::]:80;
7+
server_name *.{{ dns_domain }};
8+
server_name 172.23.0.53;
9+
{% for iface, options in dummy_interfaces.items() %}
10+
{% for ip in options.ip4 + options.ip6 %}
11+
server_name {{ ip | ipaddr('address') | ipwrap }};
12+
{% endfor %}
13+
{% endfor %}
14+
15+
location /connectionInfo {
16+
keepalive_requests 0;
17+
default_type text/plain;
18+
return 200 "$remote_addr (you) ↔ $server_addr (me)";
19+
}
20+
21+
location / {
22+
root {{ automation_root_dir }}/splash;
23+
index index-dn42.html;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>highdef.network</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link href="style.css" rel="stylesheet">
7+
</head>
8+
9+
<body>
10+
<div class="main">
11+
<h1>highdef.network</h1>
12+
<h2>AS4242421080</h2>
13+
<p>highdef is an experimental network interconnected with <a href="https://dn42.dev">dn42</a>.</p>
14+
<p>
15+
<a href="https://jlu5.com/dn42">Peering</a>
16+
-
17+
<a href="https://lg42.jlu5.com/">Looking Glass</a>
18+
</p>
19+
</div>
20+
</body>
21+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>AS4242421080 Splash Site</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link href="style.css" rel="stylesheet">
7+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.1.7/css/fork-awesome.min.css" integrity="sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" crossorigin="anonymous">
8+
</head>
9+
10+
<body>
11+
<div class="main">
12+
<h1>highdef.network</h1>
13+
<h2>AS4242421080</h2>
14+
<p>
15+
<a href="https://jlu5.com/dn42">Peering</a>
16+
-
17+
<a href="https://lg42.jlu5.com/">Looking Glass</a>
18+
</p>
19+
<hr>
20+
<h2>
21+
<i class="fa fa-server" aria-hidden="true"></i>
22+
Server info
23+
</h2>
24+
<div id="serverinfo-container">
25+
<p>Current server: <b>{{ shortname }}</b></p>
26+
<p>Test IPs: <b>{{ ownip }}</b> / <b>{{ ownip6 }}</b></p>
27+
<p>Location: <b>{{ location }}</b></p>
28+
</div>
29+
<hr>
30+
<h2>
31+
<i class="fa fa-signal" aria-hidden="true"></i>
32+
Connection info
33+
</h2>
34+
<p id="connectionInfo">
35+
<noscript><a href="connectionInfo">Click to check</a></noscript>
36+
</p>
37+
</div>
38+
<script>
39+
let req = new XMLHttpRequest();
40+
req.addEventListener("load", function() {
41+
let textContainer = document.getElementById("connectionInfo");
42+
if (this.status === 200) {
43+
textContainer.innerText = this.responseText;
44+
} else
45+
textContainer.innerText = `[Error loading: ${this.status} ${this.statusText}]`;
46+
}
47+
);
48+
req.overrideMimeType("text/plain;");
49+
req.open("GET", "connectionInfo");
50+
req.send();
51+
</script>
52+
</body>
53+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../files/style.css

‎setup-splash-site.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: Setup splash site for dn42 routers
2+
hosts: dn42routers
3+
become: yes
4+
roles:
5+
- upload-splash-site

0 commit comments

Comments
 (0)
Please sign in to comment.