Add NGINX Role tailored for stateserver usage

This commit is contained in:
Bastian 2020-11-24 18:22:03 +01:00
parent d909edc169
commit 309105d948
7 changed files with 92 additions and 0 deletions

View File

@ -19,6 +19,8 @@ yanic_database_delete_after: 720d
yanic_dbc_repondd_enable: false
nginx_ssl: true
yanic_influxdb:
- enable: true
host: http://127.0.0.1:8086

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,26 @@
---
- name: Ensure certificates are available
command:
cmd: >
openssl req -x509 -nodes -newkey rsa:2048
-keyout /etc/nginx/ssl/{{ ansible_fqdn }}.key
-out /etc/nginx/ssl/{{ ansible_fqdn }}.crt
-days 730 -subj "/CN={{ ansible_fqdn }}"
creates: /etc/nginx/ssl/{{ ansible_fqdn }}.crt
notify: Restart nginx
- name: Create web content directory
file: path=/var/www/html state=directory mode=0755
- name: Configure certificate manager
template: src=certs.j2 dest=/etc/acertmgr/{{ ansible_fqdn }}.conf
notify: Run acertmgr
- name: Configure vhosts
template: src=vhost.j2 dest=/etc/nginx/sites-available/www
notify: Restart nginx
- name: Enable vhosts
file: src=/etc/nginx/sites-available/www dest=/etc/nginx/sites-enabled/www state=link
notify: Restart nginx

View File

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

View File

@ -0,0 +1,36 @@
server {
listen 80;
listen [::]:80;
proxy_set_header X-Forwarded-For $remote_addr;
server_name _;
location /.well-known/acme-challenge {
default_type "text/plain";
alias /var/www/acme-challenge;
}
root /var/www/html;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
proxy_set_header X-Forwarded-For $remote_addr;
server_name {{ ansible_fqdn }};
ssl_certificate_key /etc/nginx/ssl/{{ ansible_fqdn }}.key;
ssl_certificate /etc/nginx/ssl/{{ ansible_fqdn }}.crt;
root /var/www/html;
location / {
proxy_pass http://localhost:3000/
}
location /meshviewer {
alias /var/www/html/meshviewer;
}
}

View File

@ -37,6 +37,7 @@
- influxdb
- grafana
- yanic
- web_stats
- name: Setup name servers
hosts: ns1.regensburg.freifunk.net