web_mc: webserver for minecraft map

This commit is contained in:
Markus 2020-12-24 12:38:42 +01:00
parent 482ac2078d
commit 39e5ad9e20
7 changed files with 81 additions and 0 deletions

View File

@ -100,6 +100,8 @@ matrix_dbname: matrix
matrix_dbuser: matrix
matrix_dbpass: "{{ vault_matrix_dbpass }}"
mc_domain: minecraft.binary-kitchen.de
nextcloud_domain: oc.binary-kitchen.de
nextcloud_dbname: owncloud
nextcloud_dbuser: owncloud

View File

@ -0,0 +1,7 @@
---
- name: Restart nginx
service: name=nginx state=restarted
- name: Run acertmgr
command: /usr/bin/acertmgr

View File

@ -0,0 +1,5 @@
---
dependencies:
- { role: acertmgr }
- { role: nginx, nginx_ssl: True }

View File

@ -0,0 +1,20 @@
---
- name: Create vhost directory
file: path=/var/www/mc state=directory owner=www-data group=www-data
- name: Ensure certificates are available
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ mc_domain }}.key -out /etc/nginx/ssl/{{ mc_domain }}.crt -days 730 -subj "/CN={{ mc_domain }}" creates=/etc/nginx/ssl/{{ mc_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager
template: src=certs.j2 dest=/etc/acertmgr/{{ mc_domain }}.conf
notify: Run acertmgr
- name: Configure vhosts
template: src=vhost.j2 dest=/etc/nginx/sites-available/mc
notify: Restart nginx
- name: Enable vhosts
file: src=/etc/nginx/sites-available/mc dest=/etc/nginx/sites-enabled/mc state=link
notify: Restart nginx

View File

@ -0,0 +1,15 @@
---
{{ mc_domain }}:
- path: /etc/nginx/ssl/{{ mc_domain }}.key
user: root
group: root
perm: '400'
format: key
action: '/usr/sbin/service nginx restart'
- path: /etc/nginx/ssl/{{ mc_domain }}.crt
user: root
group: root
perm: '400'
format: crt,ca
action: '/usr/sbin/service nginx restart'

View File

@ -0,0 +1,27 @@
server {
listen 80;
listen [::]:80;
server_name {{ mc_domain }};
location /.well-known/acme-challenge {
default_type "text/plain";
alias /var/www/acme-challenge;
}
location / {
return 301 https://{{ mc_domain }}$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ plk_domain }};
ssl_certificate_key /etc/nginx/ssl/{{ mc_domain }}.key;
ssl_certificate /etc/nginx/ssl/{{ mc_domain }}.crt;
root /var/www/mc;
}

View File

@ -104,3 +104,8 @@
hosts: technetium.binary-kitchen.net
roles:
- web_plk
- name: Setup minecraft server
hosts: ruthenium.binary-kitchen.net
roles:
- web_mc