Added role pve-nginx-redirector

roles:
  - pve-nginx-redirector

For a more admin friedly workflow this patch configures nginx to
redirect everything http://:80 and https://:443 to https://:8006 using
pve's own self-signed certificates for https://
This commit is contained in:
Jan-Jonas Sämann 2019-01-05 02:38:22 +01:00
parent 16bd6ae321
commit e916da0667
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
- name: Restart nginx
service: name=nginx state=restarted

View File

@ -0,0 +1,10 @@
---
- name: Check if nginx is installed
stat: path=/etc/nginx
register: nginx
- name: Configuring nginx pve redirector 80 -> 443 -> 8006
template: src=redirect.j2 dest=/etc/nginx/sites-enabled/redirect mode=0644
notify: Restart nginx
when: nginx.stat.exists == True

View File

@ -0,0 +1,19 @@
server {
listen {{ ansible_default_ipv4.address | default("0.0.0.0") }}:80;
location / {
return 301 https://$server_addr;
}
}
server {
listen {{ ansible_default_ipv4.address | default("0.0.0.0") }}:443 ssl;
location / {
return 301 https://$server_addr:8006;
}
ssl_certificate /etc/pve/local/pve-ssl.pem;
ssl_certificate_key /etc/pve/local/pve-ssl.key;
}