-
-
Notifications
You must be signed in to change notification settings - Fork 56
Document how to migrate the server #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -187,3 +187,113 @@ to MAIL FROM with | |||||
| and rejects incorrectly authenticated emails with [`reject_sender_login_mismatch`](reject_sender_login_mismatch) policy. | ||||||
| `From:` header must correspond to envelope MAIL FROM, | ||||||
| this is ensured by `filtermail` proxy. | ||||||
|
|
||||||
| ## Migrating chatmail server to a new host | ||||||
|
|
||||||
| If you want to migrate your chatmail server to a new host, | ||||||
| follow these steps: | ||||||
|
|
||||||
| 1. Block all ports except 80 and 22 with firewall on a new server. | ||||||
|
|
||||||
| To do this, add the following config to `/etc/nftables.conf`: | ||||||
| ``` | ||||||
| #!/usr/sbin/nft -f | ||||||
|
|
||||||
| flush ruleset | ||||||
|
|
||||||
| table inet filter { | ||||||
| chain input { | ||||||
| type filter hook input priority filter; policy drop; | ||||||
|
|
||||||
| # Accept ICMP. | ||||||
| # It is especially important to accept ICMPv6 ND messages, | ||||||
| # otherwise IPv6 connectivity breaks. | ||||||
| icmp type { echo-request } accept | ||||||
| icmpv6 type { echo-request, nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept | ||||||
|
|
||||||
| tcp dport { ssh, http } accept | ||||||
|
|
||||||
| ct state established accept | ||||||
| } | ||||||
| chain forward { | ||||||
| type filter hook forward priority filter; | ||||||
| } | ||||||
| chain output { | ||||||
| type filter hook output priority filter; | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about we add a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @hpk42's idea of stopping the services instead of adjusting the firewall. Not everyone knows how to adjust nftables. Admins will find an existing configuration at If we leave out step 1 in favor of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
no we can't, as step 2 is required for step 3's acmetool setup to work.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, if we simply copy |
||||||
| Then execute `nft -f /etc/nftables.conf` as root. | ||||||
|
|
||||||
| This will ensure users will not connect to the new server | ||||||
| and mails will not be delivered to the new server | ||||||
| before you finish the setup. | ||||||
|
|
||||||
| Port 22 is needed for SSH access | ||||||
| and port 80 is needed to get a TLS certificate. | ||||||
| They are not used by Delta Chat | ||||||
| or by other email servers trying to deliver the messages. | ||||||
|
|
||||||
| 2. Point DNS to the new IP addresses. | ||||||
|
|
||||||
| You can already remove the old IP addresses from DNS. | ||||||
| Existing Delta Chat users will still be able to connect | ||||||
| to the old server, send and receive messages, | ||||||
| but new users will fail to create new profiles | ||||||
| with your chatmail server. | ||||||
|
|
||||||
| 3. Setup the new server with `cmdeploy`. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| This step is similar to initial setup. | ||||||
| However, because ports Delta Chat uses are blocked, | ||||||
| new server will not become usable immediately. | ||||||
| If other servers try to deliver messages to your new server they will fail, | ||||||
| but normally email servers will retry delivering messages | ||||||
| for at least a week, so messages will not be lost. | ||||||
|
|
||||||
| 4. Firewall all ports except `ssh` (22) on the old server. | ||||||
|
hpk42 marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, I think just stopping dovecot + postfix is easier for admins than adjusting nftables and achieves the same result. And the know-how is more wide-spread among self-taught admins than adjusting firewalls. |
||||||
| Existing users will not be able to connect from now on | ||||||
| and no more messages will be delivered to your old chatmail server. | ||||||
|
|
||||||
| Blocking users from connecting to the new server | ||||||
| until mailboxes are migrated is needed to avoid UID validity change. | ||||||
| If Delta Chat connects to the new server before it is fully set up, | ||||||
| it will lose track of the IMAP message UID | ||||||
| and miss messages that arrived during migration. | ||||||
|
|
||||||
| Same for SMTP port 25, you want it blocked during migration so no new mails arrive | ||||||
| while the server is moving. | ||||||
|
|
||||||
| 5. Use `rsync -avz` over SSH to copy /home/vmail/mail from the old server to the new one | ||||||
| preserving file permissions and timestamps. | ||||||
|
|
||||||
| 6. Unblock ports used by Delta Chat and SMTP message exchange. | ||||||
|
hpk42 marked this conversation as resolved.
|
||||||
| For that you can modify `/etc/nftables.conf` as follows: | ||||||
|
Comment on lines
+270
to
+271
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again here, simply starting the services is much easier. Recommending firewall settings assumes a lot about the environment the chatmail server is running in; it might run on the same OS as other services which require custom configuration, it might be co-managed by other people, ... |
||||||
| ``` | ||||||
| #!/usr/sbin/nft -f | ||||||
|
|
||||||
| flush ruleset | ||||||
|
|
||||||
| table inet filter { | ||||||
| chain input { | ||||||
| type filter hook input priority filter; policy drop; | ||||||
|
|
||||||
| # Accept ICMP. | ||||||
| # It is especially important to accept ICMPv6 ND messages, | ||||||
| # otherwise IPv6 connectivity breaks. | ||||||
| icmp type { echo-request } accept | ||||||
| icmpv6 type { echo-request, nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept | ||||||
|
|
||||||
| tcp dport { ssh, smtp, http, https, imap, imaps, submission, submissions } accept | ||||||
|
|
||||||
| ct state established accept | ||||||
| } | ||||||
| chain forward { | ||||||
| type filter hook forward priority filter; | ||||||
| } | ||||||
| chain output { | ||||||
| type filter hook output priority filter; | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
| Execute `nft -f /etc/nftables.conf` as root to apply the changes. | ||||||
Uh oh!
There was an error while loading. Please reload this page.