Configuración de ISPConfig Perfect Multiserver en Ubuntu 20.04 y Debian 10 – Página 4

Configuración de ISPConfig Perfect Multiserver en Ubuntu 20.04 y Debian 10 - Página 4

5 Instalación del segundo servidor de correo

Iniciar sesión como root o ejecutar

su -

para convertirse en usuario root en su servidor antes de continuar. IMPORTANTE: debe usar ‘su -‘ y no solo ‘su’, de lo contrario, Debian configura incorrectamente su variable PATH.

5.1 Configurar el nombre de host

El nombre de host de su servidor debe ser un subdominio como «mx2.example.com». No use un nombre de dominio sin una parte de subdominio como «example.com» como nombre de host, ya que esto causará problemas más adelante con la configuración de su correo. Primero, debe verificar el nombre de host en /etc/hosts y cambiarlo cuando sea necesario. La línea debe ser: «Dirección IP – espacio – nombre de host completo, incluido el dominio – espacio – parte del subdominio». Para nuestro nombre de host mx2.example.com, el archivo se verá así:

nano /etc/hosts
127.0.0.1 localhost.localdomain   localhost
# This line should be changed on every node to the correct servername:
127.0.1.1 mx2.example.com mx2
# These lines are the same on every node:
10.0.64.12 panel.example.com panel
10.0.64.13 web01.example.com web01
10.0.64.14 mx1.example.com mx1
10.0.64.15 mx2.example.com mx2
10.0.64.16 ns1.example.com ns1
10.0.64.17 ns2.example.com ns2
10.0.64.18 webmail.example.com webmail

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Como puede ver, también agregamos los nombres de host de nuestros otros servidores, para que puedan comunicarse a través de la red interna más tarde.

Luego edite el archivo /etc/hostname:

nano /etc/hostname

Contendrá únicamente la parte del subdominio, en nuestro caso:

mx2

Finalmente, reinicie el servidor para aplicar el cambio:

systemctl reboot

Inicie sesión nuevamente y verifique si el nombre de host es correcto ahora con estos comandos:

hostname
hostname -f

La salida será así:

[email protected]:~$ hostname
mx2
[email protected]:~$ hostname -f
mx2.example.com

5.2 Instalación de ISPConfig

Ahora podemos ejecutar el instalador automático para todos los paquetes e ISPConfig:

wget -O - https://get.ispconfig.org | sh -s -- --no-dns --no-roundcube --no-mailman --use-php=system --use-unbound --interactive

Después de un tiempo, verás:

WARNING! This script will reconfigure your complete server!
It should be run on a freshly installed server and all current configuration that you have done will most likely be lost!
Type 'yes' if you really want to continue:

Responda «sí» y presione enter. Ahora se iniciará el instalador.

Cuando finalice la instalación y configuración de los paquetes, se mostrará la contraseña de root para MySQL en mx2. Anote esto (junto con el nombre del servidor, para evitar confusiones más adelante).

Ahora tendremos que responder algunas preguntas ya que estamos usando el modo interactivo. Esto es necesario ya que este servidor se agregará a su configuración multiservidor.

[INFO] Installing ISPConfig3.
[INFO] Your MySQL root password is: kl3994aMsfkkeE
--------------------------------------------------------------------------------
_____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
| | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
| |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
_| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
\___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
__/ |
|___/
--------------------------------------------------------------------------------

>> Initial configuration

Operating System: Debian 10.0 (Buster) or compatible

Following will be a few questions for primary configuration so be careful.
Default values are in [brackets] and can be accepted with <ENTER>.
Tap in "quit" (without the quotes) to stop the installer.

Select language (en,de) [en]: <-- Hit enter

Installation mode (standard,expert) [standard]: <-- expert

Full qualified hostname (FQDN) of the server, eg server1.domain.tld  [mx2.example.com]: <-- Hit Enter

MySQL server hostname [localhost]: <-- Hit Enter

MySQL server port [3306]: <-- Hit Enter

MySQL root username [root]: <-- Hit Enter

MySQL root password []: <-- Enter the MySQL password the script just gave you

MySQL database to create [dbispconfig]: <-- Hit Enter

MySQL charset [utf8]: <-- Hit Enter

The next two questions are about the internal ISPConfig database user and password.
It is recommended to accept the defaults which are 'ispconfig' as username and a random password.
If you use a different password, use only numbers and chars for the password.

ISPConfig mysql database username [ispconfig]: <-- Hit Enter

ISPConfig mysql database password [aakl203920459853sak20284204]: <-- Hit Enter

Shall this server join an existing ISPConfig multiserver setup (y,n) [n]: <-- y

MySQL master server hostname []: <-- panel.example.com

MySQL master server port []: <-- Hit Enter

MySQL master server root username [root]: <-- Hit Enter

MySQL master server root password []: <-- the password you gave the external root user on the master server.

MySQL master server database name [dbispconfig]: <-- Hit Enter

Adding ISPConfig server record to database.

Configure Mail (y,n) [y]: <-- Hit enter

Configuring Postgrey
Configuring Postfix
Generating a RSA private key
......................................................................++++
....................++++
writing new private key to 'smtpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: <-- Hit enter
State or Province Name (full name) [Some-State]: <-- Hit enter
Locality Name (eg, city) []: <-- Hit enter
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Hit enter
Organizational Unit Name (eg, section) []: <-- Hit enter
Common Name (e.g. server FQDN or YOUR name) []: <-- Hit enter
Email Address []: <-- Hit enter
[WARN] autodetect for Mailman failed
Force configure Mailman (y,n) [n]: <-- Hit enter

Skipping Mailman

Configuring Dovecot
Creating new DHParams file, this takes several minutes. Do not interrupt the script.
Configuring Spamassassin
[WARN] autodetect for Amavisd failed
Force configure Amavisd (y,n) [n]: <-- Hit enter

Skipping Amavisd

Configuring Rspamd
Configuring Getmail
Configuring Jailkit
Configuring Pureftpd
Configure DNS Server (y,n) [y]: <-- n

The Web Server option has to be enabled when you want run a web server or when this node shall host the ISPConfig interface.
Configure Web Server (y,n) [y]: <-- Hit enter

Configuring Apache
Configuring vlogger
[WARN] autodetect for OpenVZ failed
Force configure OpenVZ (y,n) [n]: <-- Hit Enter

Skipping OpenVZ

Configure Firewall Server (y,n) [y]: <-- Hit Enter

Configuring Ubuntu Firewall
[WARN] autodetect for Metronome XMPP Server failed
Force configure Metronome XMPP Server (y,n) [n]: <-- Hit Enter

Skipping Metronome XMPP Server

Configuring Fail2ban
Install ISPConfig Web Interface (y,n) [n]: <-- Hit Enter

Do you want to create SSL certs for your server? (y,n) [y]: <-- Hit Enter

Checking / creating certificate for mx2.example.com
Using certificate path /etc/letsencrypt/live/mx2.example.com
Using apache for certificate validation
Symlink ISPConfig SSL certs to Postfix? (y,n) [y]: <-- Hit Enter

Symlink ISPConfig SSL certs to Pure-FTPd? Creating dhparam file may take some time. (y,n) [y]: <-- Hit Enter

Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
......................+...........................................+...............
Configuring Apps vhost
Configuring DBServer
Installing ISPConfig crontab
no crontab for getmail
Detect IP addresses
Restarting services ...
Installation completed.
[INFO] Adding php versions to ISPConfig.
[INFO] Checking all services are running.
[INFO] mysql: OK
[INFO] clamav-daemon: OK
[INFO] postfix: OK
[INFO] bind9: OK
[INFO] pureftpd: OK
[INFO] apache2: OK
[INFO] rspamd: OK
[INFO] redis-server: OK
[INFO] dovecot: OK
[INFO] Installation ready.
[INFO] Your MySQL root password is: kl3994aMsfkkeE
[INFO] Warning: Please delete the log files in /tmp/ispconfig-ai/var/log/setup-* once you don't need them anymore because they contain your passwords!

5.3 Configuración de la replicación para Dovecot

Vamos a usar dsync para sincronizar los correos electrónicos entre mx1 y mx2, por redundancia.

Las configuraciones personalizadas para dovecot deben almacenarse en /usr/local/ispconfig/server/conf-custom/install/dovecot_custom.conf.master para que no las pierda al actualizar ISPConfig.

nano /usr/local/ispconfig/server/conf-custom/install/dovecot_custom.conf.master

Pon lo siguiente ahí:

imagen de protocolo {
  mail_plugins = cuota de $mail_plugins imap_quota notificar replicación
}
protocolo pop3 {
  mail_plugins = $mail_plugins cuota notificar replicación
}
protocolo lda {
  mail_plugins = $mail_plugins cuota de tamiz notificar replicación
}
protocolo lmtp {
  mail_plugins = $mail_plugins cuota de tamiz notificar replicación
}
doveadm_password = /(:&p-J:4e%?\@Q-;VSE#3Dmfm[fVK&r-mx2
doveadm_port = 12345
replication_max_conns = 50
ssl_client_ca_dir = /etc/ssl/certs

# Replicator process should be started at startup, so it can start replicating users immediately:
service replicator {
process_min_avail = 1
}

# The mail processes need to have access to the replication-notify fifo and socket.
service aggregator {
fifo_listener replication-notify-fifo {
user = vmail
mode = 0666
}

unix_listener replication-notify {
user = vmail
mode = 0666
}
}

# Enable doveadm replicator commands
service replicator {
unix_listener replicator-doveadm {
mode = 0666
}
}

# Create a listener for doveadm-server
service doveadm {
user = vmail
inet_listener {
port = 12345
ssl = yes
}
}
service config {
unix_listener config {
user = vmail
}
}

plugin {
mail_replica = tcps:mx1.example.com
}

Replace the doveadm_password with your own password – make it a long and random string for security reasons. It has to be the same on both servers.

Replace

mail_replica = tcps:mx1.example.com

with your own hostname of mx1.

To apply these changes, copy the file to the dovecot folder and restart dovecot:

cp /usr/local/ispconfig/server/conf-custom/install/dovecot_custom.conf.master /etc/dovecot/conf.d/99-ispconfig-custom-config.conf
systemctl restart dovecot

5.4 Setting up synchronisation for Rspamd

Rspamd has a nice web UI. We are going to set up our servers as neighbours so you can view the settings, stats, and other data in one panel.

nano /usr/local/ispconfig/server/conf-custom/install/rspamd_options.inc.master

Add these lines:

# Configuration from the ISPConfig template (must be updated if there are changes)
# Addrs local to this server.
local_addrs = [
    "127.0.0.0/8",
    "::1",
  ];  # Esta lista es generada por ISPConfig, coloque direcciones/redes personalizadas en local_networks.inc.  redes_locales = "/etc/rspamd/local.d/redes_locales.inc";  dns { servidor de nombres = ["127.0.0.1:53:10"];  } # Configuración personalizada: vecinos { mx1 { host = "https://mx1.example.com:443";  ruta = "/rspamd/";  } mx2 { anfitrión = "https://mx2.example.com:443";  ruta = "/rspamd/";  } } # Última actualización: 19-01-2022

Reemplace los nombres de host con los nombres de host correctos para su servidor de correo principal y secundario. Esta configuración debe actualizarse si la plantilla cambia, así que asegúrese de verificar esto cuando actualice ISPConfig.

Ahora vamos a agregar un sitio web para este servidor en ISPConfig. Vaya a Sitios -> Agregar nuevo sitio web y agregue el sitio web «mx2.example.com». Asegúrese de crear esto en el servidor correcto (mx2.example.com). Deshabilite el subdominio automático y habilite SSL + Let’s Encrypt. Luego, vaya a opciones y pegue esto en la sección de directivas de Apache:

RewriteEngine On
RewriteRule ^/rspamd$ /rspamd/ [R,L]
RewriteRule ^/rspamd/(.*) http://127.0.0.1:11334/$1 [P]
Header set Access-Control-Allow-Origin https://mx1.example.com

Reemplace mx1.example.com con el nombre de host del servidor de nombres secundario.

Por último, tenemos que habilitar algunos módulos de Apache y reiniciar nuestros servicios:

a2enmod proxy_balancer proxy_http
systemctl restart rspamd
systemctl restart apache2

Ahora vamos a establecer una contraseña para la interfaz de usuario de Rspamd en MX1, que usaremos como interfaz de usuario web para nuestro clúster de Rspamd.

Inicie sesión en ISPConfig como administrador y vaya a Sistema -> Configuración del servidor -> mx1.example.com -> Correo -> Contraseña Rspamd.

Introduzca una nueva contraseña y haga clic en guardar. Luego vaya a Sistema -> Configuración del servidor -> mx2.example.com -> Correo -> Contraseña Rspamd e ingrese la misma contraseña allí. Espere hasta que los cambios se propaguen. Cuando termine, puede iniciar sesión en Rspamd con su contraseña en https://mx1.ejemplo.com/rspamd/ en tu navegador.

5.5 Asegurar el servidor de correo con un certificado SSL válido

Para una configuración funcional de DSYNC y Roundcube, debe tener un certificado SSL válido para los nombres de host utilizados. Este certificado no puede ser autofirmado. Si va a utilizar nombres de host adicionales para este servidor, como imap.example.com y smtp.example.com, o si el instalador no pudo crear un certificado válido durante la instalación, siga esta guía para configurar un certificado válido para su servidor de correo. : https://www.howtoforge.com/asegurando-su-ispconfig-3-managed-mailserver-with-a-valid-lets-encrypt-certificate/

5.6 Configuración del cortafuegos

Inicie sesión en la interfaz de usuario de ISPConfig y vaya a Sistema -> Firewall. Luego haga clic en «Agregar nuevo registro de firewall».

Asegúrese de seleccionar el servidor correcto. Para nuestro servidor de correo, tenemos que abrir los siguientes puertos:

TCP:

22,25,80,110,143,443,465,587,993,995

No es necesario abrir puertos UDP a través de la interfaz de usuario.

También vamos a abrir el puerto 3306, que se usa para MySQL, y el puerto 12345, que se usa para dsync, pero solo desde nuestra red local por razones de seguridad. Para hacerlo, ejecute el siguiente comando desde la CLI, después de que se propague el cambio desde el panel ISPConfig (cuando el punto rojo desaparezca):

ufw allow from 10.0.64.0/24 to any port 3306 proto tcp
ufw allow from 10.0.64.0/24 to any port 12345 proto tcp

5.7 Duplicar MX2 desde MX1 en ISPConfig

Para finalizar la configuración, debe habilitar la duplicación entre mx1 y mx2. Para ello, inicie sesión en ISPConfig, vaya a Sistema -> mx2.example.com -> «Es espejo del servidor». Seleccione mx1.example.com y haga clic en guardar.

Nuestro servidor de correo secundario ya está instalado. En el siguiente paso, instalaremos el servidor DNS principal.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *