Tutorial: Your own mail server (Dovecot, Postfix, Rspamd) with tight Nextcloud (on Apache) integration for Debian

I’m running Mailcow for this purpose. Mailcow is a complete mailserver including postfix, dovecot, rspamd, webmail, and it gives you the lines to enter in dns, like spf, dmarc, etc.

Mailcow runs as docker compose containers and easy to set up. I know that Mailcow has an easy way to install and integrate Nextcloud in it. Just by starting an script.

This might be a good alternative to manual install for some of you.
I run Mailcow for some time now, and it is very stable. Before I used the manual install too, with lots of configurations and (security) management.

1 Like

Thank you, @PancakeConnaisseur. I have two servers set up using your tutorials at your website (123qwe.com), and they work great. I like the use of Postgresql because of the same reasons you mentioned concerning mariadb/mysql having some quirks to it. ***Edit: this is unrelated, but there is a great tutorial here: Host your own mailserver with Dovecot, Postfix, Rspamd and PostgreSQL | Pieter Hollander that configures a mailserver with DNSSEC. He also has some other very cool tutorials. You might to be able to add a Nextcloud configuration on top of his tutorial. I should mention this site also: Mailserver mit Dovecot, Postfix, MySQL und Rspamd unter Debian 10 Buster [v1.0]

1 Like

Thanks for the links. I will check them out and maybe take some inspiration for my next release. There might not be a next version of the tutorial in its current form though, since I switched to NixOS recently and am moving all my servers to it.

I didn’t have time to follow this thread for a long time. In case you still are interested in answers:

Docker containers are not planned currently.

I had quite a journey while looking for a way to improve the speed of the set-up and automation in general. I started looking into Docker containers, but found them not suiting my needs. I don’t want that much isolation of the services and I have yet to find a good upgrade strategy for Docker containers. I use them at work, but want something “cleaner” and “simpler” for my private use. I then started porting the configuration to Ansible and that worked out well and I would have used that, had I not found NixOS. After some experimentation, this is the OS of my choice currently. Its a big time investment learning it, but I hope it will pay dividends in the future.

You can use a dynamic DNS provider such as https://desec.io/. You need to setup your router to contact their service whenever your public IP changes. A DNS provider will then give you a domain name which will always redirect to that IP. Many also allow to use your own domain for that.

Hello and so far thank you for your Tutorial.

Unfortunally i now upgraded from a long deprecated install (which was still working, albeit everything, Debian 10, Postgresql 11 and Nextcloud 24) where ‘slighly’ Dusty.

Now i have NExtcloud 31, Postgresql 15 (database is still 13) and Debian 12.

Unforunally Nextcloud isnt running anymore as it should be, i can only log in as an admin, and as soon as i try to surf to the webseites for either users, Administration overview or try to login with another user then admin i get an internal server error.

If i interpreted the nextcloud log correctly everything points to the Plugin
User Backend SQL Raw, which apparently had some changes to its syntax. The old one with dbname, dpuser and dppassword is overturned by some “dsn” structure.

But i still cant manage to get a connection to the database (which i presume is the reason for my issues with nextcloud.

At least the mailserver still runs as it should.

Do you have an idea what changes i need to make in regards to your Tutorial to conform with the current syntax?

best regards Schwarzie

The exact error line from the nextcloud.log is:

<l_server", SSL off"]},“CustomMessage”:“Could not boot encryption: SQLSTATE[08006] [7] connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: no pg_hba.conf entry for host "[local]", user "mail_admin", database "mail_server", SSL off”}}

So maybe an issue with the deprecated md5 password encryption method in postgresql 13+?


Update!

YES, it was md5.

I enforced scram-sha-256 in the postgresql.conf and then rehashed the passwords for my users (especially mail_admin) and i now once again have access to all my users and the file sync works again.

I also added a line to my pg_hba.conf with local all mail:admin scram-sha-256. No idea if that was necessary, but i dont care it now works.

And all of that on a up to date Linux VPS that officially should support userbackendsqlraw because that supposedly works only until NExtcloud 29 (but apparently works with 31 aswell). YAY.

So even a total Linux noob can do it with a week of vacation, some bottles of wine and a frustration tolerance trained as a kid with R-Type on a Gameboy :wink:
All hail to Snapshots.

Now i just need to finally upgrade Postgres to 15+…