aboutsummaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/personal/tasks/main.yml39
-rw-r--r--roles/personal/templates/htpasswd.j29
-rw-r--r--roles/personal/templates/nginx.conf.j274
3 files changed, 122 insertions, 0 deletions
diff --git a/roles/personal/tasks/main.yml b/roles/personal/tasks/main.yml
new file mode 100644
index 0000000..6a9b7c7
--- /dev/null
+++ b/roles/personal/tasks/main.yml
@@ -0,0 +1,39 @@
1---
2- block:
3 - name: Ensure personal web root exists
4 ansible.builtin.file:
5 path: /srv/http/michalec.dev
6 state: directory
7 owner: cmmm
8 group: www-data
9 mode: '0775'
10
11 - name: Ensure nginx site modular directory exists
12 ansible.builtin.file:
13 path: /etc/nginx/http.d/michalec.dev.d
14 state: directory
15 owner: root
16 group: root
17 mode: '0755'
18
19 - name: Deploy personal nginx site configuration
20 ansible.builtin.template:
21 src: nginx.conf.j2
22 dest: /etc/nginx/http.d/personal.conf
23 owner: root
24 group: root
25 mode: '0444'
26 validate: nginx-validate %s /etc/nginx/http.d/personal.conf
27 notify: Reload nginx
28
29 - name: Deploy personal nginx htpasswd
30 ansible.builtin.template:
31 src: htpasswd.j2
32 dest: /etc/nginx/htpasswd
33 owner: root
34 group: nginx
35 mode: '0440'
36 notify: Reload nginx
37
38 tags:
39 - personal
diff --git a/roles/personal/templates/htpasswd.j2 b/roles/personal/templates/htpasswd.j2
new file mode 100644
index 0000000..657d165
--- /dev/null
+++ b/roles/personal/templates/htpasswd.j2
@@ -0,0 +1,9 @@
1$ANSIBLE_VAULT;1.1;AES256
265393532343134393463373936346137323139636165363530323337636631613632323563316536
36464356539343231643763653562303734666566653736630a373566623364626365373939393136
438643961616536393664353563623032376663363430333439393363663838303838376363653731
53462323538623962630a393661626161333464323139333265626236396537366266663766663635
661383562383562633638643239643230336164663030623261363934363865373630633563656335
737633665373265666339303065613737383431353736613034393264303964323663393162623335
838343062346464653263306566336232616638383332343433393630343934636232376566313138
962303331633538663365
diff --git a/roles/personal/templates/nginx.conf.j2 b/roles/personal/templates/nginx.conf.j2
new file mode 100644
index 0000000..fdb869b
--- /dev/null
+++ b/roles/personal/templates/nginx.conf.j2
@@ -0,0 +1,74 @@
1# -*- Nginx -*-
2# {{ ansible_managed }}
3
4server {
5 listen 80;
6 listen [::]:80;
7 server_name michalec.dev
8 www.michalec.dev
9 git.michalec.dev
10 lists.michalec.dev;
11
12 location ^~ /.well-known/acme-challenge/ {
13 root /var/www/acme;
14 }
15
16 location / {
17 return 307 https://$host$request_uri;
18 }
19}
20
21server {
22 server_name michalec.dev
23 www.michalec.dev;
24
25 listen unix:/var/run/nginx/http.sock;
26 listen 443 ssl;
27 listen [::]:443 ssl;
28 listen 443 quic reuseport;
29 listen [::]:443 quic reuseport;
30
31 http2 on;
32 http3 on;
33
34 add_header Alt-Svc 'h3=":443"; ma=86400';
35
36 ssl_certificate /etc/ssl/michalec.dev.fullchain.pem;
37 ssl_certificate_key /etc/ssl/private/michalec.dev.key;
38 ssl_protocols TLSv1.2 TLSv1.3;
39
40 root /srv/http/michalec.dev;
41 index index.html;
42
43 location /private/ {
44 auth_basic "private";
45 auth_basic_user_file /etc/nginx/htpasswd;
46
47 try_files $uri $uri/ =404;
48
49 location = /private/status {
50 stub_status;
51 }
52 }
53
54 location /files/ {
55 alias /srv/http/michalec.dev/;
56 index nonexistent;
57 autoindex on;
58 }
59 location /files/private/ {
60 alias /srv/http/michalec.dev/private/;
61 index nonexistent;
62 autoindex on;
63
64 auth_basic "private";
65 auth_basic_user_file /etc/nginx/htpasswd;
66 }
67
68 location /en/ { try_files $uri $uri/ =404; }
69 location /ru/ { try_files $uri $uri/ =404; }
70 location /sk/ { try_files $uri $uri/ =404; }
71 location / { try_files $uri /en$uri /en$uri/ =404; }
72
73 include /etc/nginx/http.d/michalec.dev.d/*.conf;
74}