Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmdeploy/src/cmdeploy/deployers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .filtermail.deployer import FiltermailDeployer
from .mtail.deployer import MtailDeployer
from .nginx.deployer import NginxDeployer
from .websockify.deployer import WebsockifyDeployer
from .opendkim.deployer import OpendkimDeployer
from .postfix.deployer import PostfixDeployer
from .selfsigned.deployer import SelfSignedTlsDeployer
Expand Down Expand Up @@ -565,6 +566,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) -
PostfixDeployer(config, disable_mail),
FcgiwrapDeployer(),
NginxDeployer(config),
WebsockifyDeployer(config),
MtailDeployer(config.mtail_address),
GithashDeployer(),
]
Expand Down
14 changes: 14 additions & 0 deletions cmdeploy/src/cmdeploy/nginx/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ http {
proxy_pass http://127.0.0.1:3340;
proxy_http_version 1.1;
}

location /imap {
proxy_pass http://127.0.0.1:8143;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location /smtp {
proxy_pass http://127.0.0.1:8587;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

# Redirect www. to non-www
Expand Down
19 changes: 19 additions & 0 deletions cmdeploy/src/cmdeploy/websockify/deployer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pyinfra.operations import apt, server

from cmdeploy.basedeploy import Deployer


class WebsockifyDeployer(Deployer):
def __init__(self, config):
self.config = config

def install(self):
apt.packages(name="Install websockify", packages=["websockify"])

def configure(self):
self.ensure_systemd_unit("websockify/websockify-imap.service")
self.ensure_systemd_unit("websockify/websockify-submission.service")

def activate(self):
self.ensure_service("websockify-imap.service")
self.ensure_service("websockify-submission.service")
12 changes: 12 additions & 0 deletions cmdeploy/src/cmdeploy/websockify/websockify-imap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=WebSocket proxy for IMAP
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/websockify 127.0.0.1:8143 localhost:143
DynamicUser=true

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions cmdeploy/src/cmdeploy/websockify/websockify-submission.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=WebSocket proxy for SMTP
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/websockify 127.0.0.1:8587 localhost:587
DynamicUser=true

[Install]
WantedBy=multi-user.target