diff --git a/seed/applicationservice/2022.03.08/dovecot/applicationservice.yml b/seed/applicationservice/2022.03.08/dovecot/applicationservice.yml
index 6246bebe..3482af25 100644
--- a/seed/applicationservice/2022.03.08/dovecot/applicationservice.yml
+++ b/seed/applicationservice/2022.03.08/dovecot/applicationservice.yml
@@ -5,3 +5,4 @@ depends:
- relay-mail-client
- ldap-client-fedora
- oauth2-client
+ - nginx-common
diff --git a/seed/applicationservice/2022.03.08/dovecot/dictionaries/22_dovecot.xml b/seed/applicationservice/2022.03.08/dovecot/dictionaries/22_dovecot.xml
index 229fcd63..1348cb72 100644
--- a/seed/applicationservice/2022.03.08/dovecot/dictionaries/22_dovecot.xml
+++ b/seed/applicationservice/2022.03.08/dovecot/dictionaries/22_dovecot.xml
@@ -18,9 +18,15 @@
+ /etc/nginx/conf.d/autoconfig.conf
+
+
+ well_known_filenames
+ revprox_ca_file
+ revprox_cert_file
+ revprox_key_file
- revprox_ca_file
/sysusers.d/1dovecot.conf
/tmpfiles.d/0dovecot.conf
/etc/dovecot/conf.d/10-logging.conf
@@ -63,6 +69,7 @@
+
@@ -70,6 +77,8 @@
+
+
@@ -78,6 +87,8 @@
+
+
@@ -107,6 +118,18 @@
/
revprox_ca_file
+
+ tls_cert_directory
+ revprox.crt
+ /
+ revprox_cert_file
+
+
+ tls_key_directory
+ revprox.key
+ /
+ revprox_key_file
+
/etc/pki/tls/certs/imap_
imap_domainname
@@ -131,5 +154,46 @@
True
postfix_pem_files
+
+ mail_domains
+ True
+ mail_domains_calc
+
+
+ /var/www/html/mail/
+ mail_domains
+ /autodiscover/autodiscover.xml
+
+
+ True
+ well_known_filenames
+
+
+ revprox_server_domainname
+ revprox_clients
+ revprox_location
+ /.well-known/autoconfig/mail/config-v1.1.xml
+ revprox_is_websocket
+ False
+ revprox_url
+ well_knowns
+ mail_domains_calc
+
+
+ revprox_server_domainname
+ revprox_clients
+ revprox_location
+ /autodiscover/autodiscover.xml
+ revprox_is_websocket
+ False
+ revprox_url
+ well_knowns
+ mail_domains_calc
+
+
+ domain_name_eth0
+ mail_domains
+ well_knowns
+
diff --git a/seed/applicationservice/2022.03.08/dovecot/funcs/dovecot.py b/seed/applicationservice/2022.03.08/dovecot/funcs/dovecot.py
index b1130132..415c5277 100644
--- a/seed/applicationservice/2022.03.08/dovecot/funcs/dovecot.py
+++ b/seed/applicationservice/2022.03.08/dovecot/funcs/dovecot.py
@@ -1,9 +1,20 @@
from crypt import crypt as _crypt
from string import ascii_letters as _ascii_letters, digits as _digits
from secrets import choice as _choice
+from risotto.utils import multi_function as _multi_function
def sha512_crypt(password):
salt = ''.join([_choice(_ascii_letters + _digits) for _ in range(8)])
prefix = '$6$'
return _crypt(password, prefix + salt)
+
+
+@_multi_function
+def calc_well_known(*args):
+ if None in args:
+ return
+ ret = []
+ for dom in args[1]:
+ ret.append(f'https://{args[0]}/mail/{dom}/autodiscover/autodiscover.xml')
+ return ret
diff --git a/seed/applicationservice/2022.03.08/dovecot/manual/image/preinstall/postfix_dovecot.sh b/seed/applicationservice/2022.03.08/dovecot/manual/image/preinstall/postfix_dovecot.sh
index ea7db559..faa4e341 100644
--- a/seed/applicationservice/2022.03.08/dovecot/manual/image/preinstall/postfix_dovecot.sh
+++ b/seed/applicationservice/2022.03.08/dovecot/manual/image/preinstall/postfix_dovecot.sh
@@ -1 +1 @@
-PKG="$PKG postfix-ldap dovecot cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain"
+PKG="$PKG postfix-ldap dovecot cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain nginx"
diff --git a/seed/applicationservice/2022.03.08/dovecot/templates/autoconfig.conf b/seed/applicationservice/2022.03.08/dovecot/templates/autoconfig.conf
new file mode 100644
index 00000000..8be4082e
--- /dev/null
+++ b/seed/applicationservice/2022.03.08/dovecot/templates/autoconfig.conf
@@ -0,0 +1,12 @@
+server {
+ listen 443 ssl;
+ server_name %%domain_name_eth0;
+
+ ssl_client_certificate %%revprox_ca_file;
+ ssl_certificate %%revprox_cert_file;
+ ssl_certificate_key %%revprox_key_file;
+
+ root /var/www/html/;
+ # To allow POST on static pages
+ error_page 405 =200 $uri;
+}
diff --git a/seed/applicationservice/2022.03.08/dovecot/templates/config-v1.1.xml b/seed/applicationservice/2022.03.08/dovecot/templates/config-v1.1.xml
new file mode 100644
index 00000000..305ee0eb
--- /dev/null
+++ b/seed/applicationservice/2022.03.08/dovecot/templates/config-v1.1.xml
@@ -0,0 +1,27 @@
+
+# GNUNUX: from https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat -->
+%set %%domain = %%rougail_variable
+%set %%leader = %%mail_domains[%%mail_domains.index(%%domain)]
+%set %%imap_domain = %%leader.imap_domainname
+%set %%submission_domain = %%leader.submission_domainname
+
+
+ %%domain
+ Services %%domain
+ %%domain
+
+ %%imap_domain
+ 993
+ SSL
+ %EMAILADDRESS%
+ password-cleartext
+
+
+ %%submission_domain
+ 587
+ STARTTLS
+ %EMAILADDRESS%
+ password-cleartext
+
+
+
diff --git a/seed/applicationservice/2022.03.08/dovecot/templates/revprox.crt b/seed/applicationservice/2022.03.08/dovecot/templates/revprox.crt
new file mode 100644
index 00000000..14fccb1f
--- /dev/null
+++ b/seed/applicationservice/2022.03.08/dovecot/templates/revprox.crt
@@ -0,0 +1,2 @@
+%%get_certificate(%%domain_name_eth0, authority_cn=%%revprox_server_domainname, authority_name='InternalReverseProxy', type="server")
+%%get_chain(%%revprox_server_domainname, 'InternalReverseProxy')
diff --git a/seed/applicationservice/2022.03.08/dovecot/templates/revprox.key b/seed/applicationservice/2022.03.08/dovecot/templates/revprox.key
new file mode 100644
index 00000000..649ae0bc
--- /dev/null
+++ b/seed/applicationservice/2022.03.08/dovecot/templates/revprox.key
@@ -0,0 +1 @@
+%%get_private_key(%%domain_name_eth0, authority_cn=%%revprox_server_domainname, authority_name='InternalReverseProxy', type='server')