email: Install rspamd; proxy its web interface

This commit is contained in:
fliu 2021-07-01 09:34:15 +00:00 committed by Sunil Mohan Adapa
parent 758c8791f1
commit 7166e63b02
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
4 changed files with 60 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import plinth.daemon
import plinth.frontpage import plinth.frontpage
import plinth.menu import plinth.menu
from plinth import actions from plinth import actions
from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall from plinth.modules.firewall.components import Firewall
from . import audit from . import audit
@ -16,7 +17,8 @@ from . import manifest
version = 1 version = 1
managed_packages = ['postfix', 'dovecot-pop3d', 'dovecot-imapd', managed_packages = ['postfix', 'dovecot-pop3d', 'dovecot-imapd',
'dovecot-lmtpd', 'dovecot-ldap', 'dovecot-managesieved'] 'dovecot-lmtpd', 'dovecot-ldap', 'dovecot-managesieved',
'rspamd']
managed_services = ['postfix', 'dovecot'] managed_services = ['postfix', 'dovecot']
app = None app = None
@ -50,6 +52,11 @@ class EmailServerApp(plinth.app.App):
) )
self.add(menu_item) self.add(menu_item)
# /rspamd location
webserver = Webserver('webserver-email', 'email-server-freedombox',
urls=['https://{host}/rspamd'])
self.add(webserver)
shortcut = plinth.frontpage.Shortcut( shortcut = plinth.frontpage.Shortcut(
'shortcut_' + self.app_id, 'shortcut_' + self.app_id,
name=info.name, name=info.name,
@ -96,6 +103,7 @@ def setup(helper, old_version=None):
"""Installs and configures module""" """Installs and configures module"""
helper.install(managed_packages) helper.install(managed_packages)
helper.call('post', audit.ldap.repair) helper.call('post', audit.ldap.repair)
helper.call('post', audit.spam.repair)
helper.call('post', app.enable) helper.call('post', app.enable)
for service_name in managed_services: for service_name in managed_services:
actions.superuser_run('service', ['reload', service_name]) actions.superuser_run('service', ['reload', service_name])

View File

@ -5,5 +5,6 @@ Provides diagnosis and repair of email server configuration issues
from . import ldap from . import ldap
from . import domain from . import domain
from . import spam
__all__ = ['ldap', 'domain'] __all__ = ['ldap', 'domain', 'spam']

View File

@ -0,0 +1,26 @@
"""Configures spam filters and the virus scanner"""
# SPDX-License-Identifier: AGPL-3.0-or-later
import logging
from plinth import actions
import plinth.modules.email_server.postconf as postconf
milter_config = {
'milter_mail_macros': 'i {auth_type} {auth_authen} {auth_author} '\
'{client_addr} {client_name} {mail_addr} {mail_host} {mail_mailer}',
'smtpd_milters': 'inet:127.0.0.1:11332',
'non_smtpd_milters': 'inet:127.0.0.1:11332'
}
logger = logging.getLogger(__name__)
def repair():
logger.debug('Updating postconf: %r', milter_config)
actions.superuser_run('email_server', ['ipc', 'spam', 'set_filter'])
def action_set_filter():
postconf.set_many(milter_config)

View File

@ -0,0 +1,23 @@
<Location ~ "/rspamd$">
Redirect "/rspamd/"
</Location>
<Location ~ "/rspamd/">
ProxyPass http://127.0.0.1:11334/
ProxyPassReverse http://127.0.0.1:11334/
# Modify proxy headers
ProxyAddHeaders off
RequestHeader unset Forwarded
RequestHeader unset Via
RequestHeader unset X-Forwarded-For
RequestHeader unset X-Forwarded-Host
RequestHeader unset X-Forwarded-Proto
RequestHeader unset X-Forwarded-Server
RequestHeader unset X-Real-IP
RequestHeader set X-Forwarded-For "127.0.0.1"
# Require SSO
Include includes/freedombox-single-sign-on.conf
<IfModule mod_auth_pubtkt.c>
TKTAuthToken "admin"
</IfModule>
</Location>