diff --git a/tasks/main.yml b/tasks/main.yml index 06bdbec..dca830a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -61,3 +61,8 @@ import_tasks: roundcubemail.yml tags: roundcubemail +- name: Run MX-Domain Website + when: mailserver_website != "" + import_tasks: website.yml + tags: website + diff --git a/tasks/website.yml b/tasks/website.yml new file mode 100644 index 0000000..dfcb4a2 --- /dev/null +++ b/tasks/website.yml @@ -0,0 +1,23 @@ +- name: website - get cert for nginx domain + notify: dehydrated + when: mailserver_mx_domain != "" + lineinfile: + path: /etc/dehydrated/domains.txt + line: "{{ mailserver_mx_domain }}" + +- name: website - nginx domain + notify: reload nginx + when: mailserver_mx_domain != "" + template: + src: mxdomain-website-domain.nginx + dest: /etc/nginx/sites.d/mxdomain.act + +- name: website - directory + file: + state: directory + path: "/srv/http/{{ mailserver_mx_domain }}" + +- name: website - index.html + template: + src: mxdomain-website.html + dest: "/srv/http/{{ mailserver_mx_domain }}/index.html" diff --git a/templates/mxdomain-website-domain.nginx b/templates/mxdomain-website-domain.nginx new file mode 100644 index 0000000..bbfebc8 --- /dev/null +++ b/templates/mxdomain-website-domain.nginx @@ -0,0 +1,14 @@ +server { + listen [::]:443 ssl http2; + listen 443 ssl http2; + + server_name {{ mailserver_mx_domain }}; + + ssl_certificate /etc/dehydrated/certs/{{ mailserver_mx_domain }}/fullchain.pem; + ssl_certificate_key /etc/dehydrated/certs/{{ mailserver_mx_domain }}/privkey.pem; + + include snippets/letsencrypt.conf; + + root /srv/http/{{ mailserver_mx_domain }}; + index index.html index.htm index.php; +} diff --git a/templates/mxdomain-website.html b/templates/mxdomain-website.html new file mode 100644 index 0000000..318cc88 --- /dev/null +++ b/templates/mxdomain-website.html @@ -0,0 +1,3 @@ +