Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:postfixadmin_archlinux

PostfixAdmin ArchLinux

PostfixAdmin ist eine quell-offene, webbasierte Schnittstelle (Web-Anwendung) zur Verwaltung von Domänen/Postfächern/Aliase uvm. auf einem Postfix-basierten Mailserver.

Ab hier werden zur Ausführung nachfolgender Befehle root-Rechte benötigt. Um der Benutzer root zu werden, melden Sie sich bitte als root-Benutzer am System an, oder wechseln mit nachfolgendem Befehl zum Benutzer root:

$ su -
Password:

Voraussetzungen

Um PostfixAdmin installieren und betreiben zu können, sind folgende Komponenten erforderlich:

Installation: postfixadmin

Zur Installation des PostfixAdmin wird nachfolgendes Paket benötigt:

  • postfixadmin - ist im extra-Repository von ArchLinux enthalten.

Mit nachfolgendem Befehl, wird das Pakete postfixadmin installiert:

# pacman -S --noconfirm postfixadmin

Installationsverlauf

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket postfixadmin installiert wurden:

# pacman -Qil postfixadmin

Installierte Dateien

Konfiguration: MariaDB Datenbank

Damit PostfixAdmin genutzt werden kann, muss dieses ein Backend-System zur Datenhaltung haben, welches hier aktuell eine MariaDB-Datenbanksystem sein soll.

Um nachfolgende Befehle ausführen zu können, muss eine Anmeldung am MariaDB-Datenbanksystem mit einem Benutzer, welcher einen administrativen Zugriff auf die Datenbank hat, erfolgen können.

Als erstes ist es erforderlich innerhalb eines MariaDB-Datenbanksystem, hier eine MariaDB-Datenbank anzulegen. Das nachfolgende kleine Skript soll

  • eine Datenbank mit dem Namen postfix anlegen
  • einen Benutzer mit dem Namen postfixuser anlegen
  • ein Passwort das geheim lautet dem Benutzer postfixuser zuweisen
  • dem Benutzer postfixuser entsprechende Rechte für die Datenbank postfix erteilen.

MariaDB: Datenbank anlegen

Mit nachfolgendem Befehl soll nun eine SQL-Datei in nachfolgendem Verzeichnis, mit nachfolgendem Namen und nachfolgendem Inhalt erstellt werden.

SQL-Datei Verwendungszweck
/tmp/create_database_postfix.sql Erstellung einer Datenbank
# vim /tmp/create_database_postfix.sql

Die SQL-Datei /tmp/create_database_postfix.sql soll nachfolgenden Inhalt bekommen:

-- MariaDB-SQL-Script.
-- Create database postfix
-- (c) Klaus Tachtler 2024.
-- /usr/bin/mariadb -h 127.0.0.1 -u root -p < <script.sql>
 
-- CREATE DATABASE postfix;
CREATE DATABASE IF NOT EXISTS postfix DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;

Abschliessend wird mit nachfolgendem Befehl der Inhalt der SQL-Datei im laufendem Betrieb des MariaDB-Datenbank-Servers der Konfiguration des MariaDB-Datenbank-Servers hinzugefügt:

# /usr/bin/mariadb -h 127.0.0.1 -u root -p < /tmp/create_database_postfix.sql
Enter password:

:!: WICHTIG - Es wird die Kenntnis des Passwortes für den Benutzer root vorausgesetzt!.

Mit nachfolgenden Befehlen kann nun überprüft werden, ob die vorhergehenden Schritte zur Einrichtung einer neuen Datenbank erfolgreich waren.

Nachfolgender Befehl ermöglicht die Anmeldung am MariaDB-Monitor:

# /usr/bin/mariadb -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 11.4.4-MariaDB Arch Linux
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]

Nachfolgender Befehl listet den angelegten Remote-Benutzer mit allen Details auf:

MariaDB [(none)]> SHOW databases LIKE 'postfix';
+--------------------+
| Database (postfix) |
+--------------------+
| postfix            |
+--------------------+
1 row in set (0.002 sec)
 
MariaDB [(none)]>

Nachfolgender Befehl beendet den MariaDB-Monitor:

MariaDB [(none)]> quit
Bye

Abschliessend kann dann noch die Datei /tmp/create_database_postfix.sql welche sich noch im /tmp-Verzeichnis befindet, mit nachfolgendem Befehl gelöscht werden:

# rm -f /tmp/create_database_postfix.sql

MariaDB: Benutzer anlegen

:!: HINWEIS - Es wird der Zugriff von mindestens zwei Servern aus ermöglicht (Postfix (main server) & Dovecot) !

Um ein Passwort im verschlüsselten Format für das Passwort-Feld der nachfolgenden SQL-Datei zu erstellen, kann nachfolgender Befehl genutzt werden.

:!: WICHTIG - Es wird die Kenntnis des Passwortes für den Benutzer root vorausgesetzt!.

# echo "SELECT PASSWORD('geheim');" | /usr/bin/mariadb -h 127.0.0.1 -u root -p
Enter password: 
PASSWORD('geheim')
*462366917EEDD1970A48E87D8EF59EB67D2CA26F

Mit nachfolgendem Befehl soll nun eine SQL-Datei in nachfolgendem Verzeichnis, mit nachfolgendem Namen und nachfolgendem Inhalt erstellt werden.

SQL-Datei Verwendungszweck
/tmp/create_users_for_remote_access_to_database_postfix.sql Erstellung eines Remote-Benutzers
# vim /tmp/create_users_for_remote_access_to_database_postfix.sql

Die SQL-Datei /tmp/create_users_for_remote_access_to_database_postfix.sql soll nachfolgenden Inhalt bekommen:

-- MariaDB-SQL-Script.
-- Create users for remote access to database guacamole. 
-- (c) Klaus Tachtler 2024.
-- /usr/bin/mariadb -h 127.0.0.1 -u root -p < <script.sql>
 
-- Use database.
USE mysql;
 
-- Create new users.
CREATE USER 'postfixuser'@'10.0.0.60' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
CREATE USER 'postfixuser'@'fd00::10:10:0:0:60' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
CREATE USER 'postfixuser'@'vml060.idmz.tachtler.net' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
CREATE USER 'postfixuser'@'10.0.0.80' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
CREATE USER 'postfixuser'@'fd00::10:10:0:0:80' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
CREATE USER 'postfixuser'@'vml080.idmz.tachtler.net' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
 
-- Grant privileges for database postfix to new users.
GRANT USAGE ON *.* TO 'postfixuser'@'10.0.0.60' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT USAGE ON *.* TO 'postfixuser'@'fd00::10:10:0:0:60' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT USAGE ON *.* TO 'postfixuser'@'vml060.idmz.tachtler.net' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'10.0.0.60';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'fd00::10:10:0:0:60';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'vml060.idmz.tachtler.net';
GRANT USAGE ON *.* TO 'postfixuser'@'10.0.0.80' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT USAGE ON *.* TO 'postfixuser'@'fd00::10:10:0:0:80' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT USAGE ON *.* TO 'postfixuser'@'vml080.idmz.tachtler.net' IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'10.0.0.80';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'fd00::10:10:0:0:80';
GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfixuser'@'vml080.idmz.tachtler.net';
 
-- Make sure that priviliges are reloaded.
FLUSH PRIVILEGES;

Abschliessend wird mit nachfolgendem Befehl der Inhalt der SQL-Datei im laufendem Betrieb des MariaDB-Datenbank-Servers der Konfiguration des MariaDB-Datenbank-Servers hinzugefügt:

# /usr/bin/mariadb -h 127.0.0.1 -u root -p < /tmp/create_users_for_remote_access_to_database_postfix.sql
Enter password:

Mit nachfolgenden Befehlen kann nun überprüft werden, ob die vorhergehenden Schritte zur Einrichtung eines Remote-Benutzers erfolgreich waren.

Nachfolgender Befehl ermöglicht die Anmeldung am MariaDB-Monitor:

# /usr/bin/mariadb -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 11.4.4-MariaDB Arch Linux
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]>

Nachfolgender Befehl listet den angelegten Remote-Benutzer mit allen Details auf:

MariaDB [(none)]> SELECT * FROM mysql.user WHERE User = 'postfixuser';
+--------------------------+-------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
| Host                     | User        | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | Delete_history_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin                | authentication_string                     | password_expired | is_role | default_role | max_statement_time |
+--------------------------+-------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
| 10.0.0.60                | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
| fd00::10:10:0:0:60       | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
| vml060.idmz.tachtler.net | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
| 10.0.0.80                | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
| fd00::10:10:0:0:80       | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
| vml080.idmz.tachtler.net | postfixuser | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *462366917EEDD1970A48E87D8EF59EB67D2CA26F | N                | N       |              |           0.000000 |
+--------------------------+-------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
6 rows in set (0.004 sec)
 
MariaDB [(none)]>

Nachfolgende Befehle listen die Rechte des Benutzers postfixuser für die Datenbank postfix auf:

MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'10.0.0.60';
+--------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@10.0.0.60                                                                                   |
+--------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`10.0.0.60` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`10.0.0.60`                                                   |
+--------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
 
MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'10.0.0.60';
+--------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@10.0.0.60                                                                                   |
+--------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`10.0.0.60` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`10.0.0.60`                                                   |
+--------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.001 sec)
 
MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'vml060.idmz.tachtler.net';
+-----------------------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@vml060.idmz.tachtler.net                                                                                   |
+-----------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`vml060.idmz.tachtler.net` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`vml060.idmz.tachtler.net`                                                   |
+-----------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
 
MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'10.0.0.80';
+--------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@10.0.0.80                                                                                   |
+--------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`10.0.0.80` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`10.0.0.80`                                                   |
+--------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
 
MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'fd00::10:10:0:0:80';
+-----------------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@fd00::10:10:0:0:80                                                                                   |
+-----------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`fd00::10:10:0:0:80` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`fd00::10:10:0:0:80`                                                   |
+-----------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.001 sec)
 
MariaDB [(none)]> SHOW GRANTS FOR 'postfixuser'@'vml080.idmz.tachtler.net';
+-----------------------------------------------------------------------------------------------------------------------------------+
| Grants for postfixuser@vml080.idmz.tachtler.net                                                                                   |
+-----------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `postfixuser`@`vml080.idmz.tachtler.net` IDENTIFIED BY PASSWORD '*462366917EEDD1970A48E87D8EF59EB67D2CA26F' |
| GRANT ALL PRIVILEGES ON `postfix`.* TO `postfixuser`@`vml080.idmz.tachtler.net`                                                   |
+-----------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.001 sec)

Nachfolgender Befehl beendet den MariaDB-Monitor:

MariaDB [(none)]> quit
Bye

Abschliessend kann dann noch die Datei /tmp/create_users_for_remote_access_to_database_postfix.sql welche sich noch im /tmp-Verzeichnis befindet, mit nachfolgendem Befehl gelöscht werden:

# rm -f /tmp/create_users_for_remote_access_to_database_postfix.sql

Konfiguration: Apache Webserver

Es soll anstelle der mitgelieferten Konfigurationsdatei in nachfolgendem Verzeichnis, mit nachfolgendem Namen:

  • /etc/httpd/conf/vhosts/postfixadmin.conf

ein virtueller Host im Apache HTTP Server eingerichtet werden.

Siehe dazu auch nachfolgende interne Links:

Apache Webserver: /etc/httpd/conf/vhosts/postfixadmin.conf

Zusätzlich ist die Einrichtung eines virtuellen Host mit nachfolgender Konfiguration erforderlich. Die Konfigurationsdatei sollte unter nachfolgendem Verzeichnis mit nachfolgendem Namen neu erstellt werden:

# mkdir /etc/httpd/conf/vhost
# vim /etc/httpd/conf/vhost/postfixadmin.conf

Der Inhalt der so neu erstellten Konfigurationsdatei für den virtuellen Host des Apache HTTPD Webserver könnt in etwa wie folgt aussehen:

(Komplette Konfigurationsdatei)

<VirtualHost *:80>
    ServerAdmin webmaster@tachtler.net
    ServerName postfixadmin.tachtler.net
    ServerPath /
 
    # ----------------------------------------------------------
    # Rewrite settings
    # Rewrite the requestet URI - PERMANENT - to HTTPS and leave
    # this virtual Host to the HTTPS variant of it.
    # ----------------------------------------------------------
    <IfModule rewrite_module>
        RewriteEngine On
        RewriteCond "%{HTTPS}" "!=on"
        RewriteRule "^(.*)$" "https://%{HTTP_HOST}%{REQUEST_URI}" [R=301,L]
    </IfModule>
 
    # ----------------------------------------------------------
    # Logging settings
    # ----------------------------------------------------------
    <IfModule log_config_module>
        ErrorLog /var/log/httpd/postfixadmin.tachtler.net_error.log
        SetEnvIF User-Agent "HAProxy" dontlog=yes
        SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded=yes
        <IfModule logio_module>
            CustomLog /var/log/httpd/postfixadmin.tachtler.net_access.log combined_deflate_ssl "expr=(reqenv('forwarded') != 'yes' && reqenv('dontlog') != 'yes')"
            CustomLog /var/log/httpd/postfixadmin.tachtler.net_access.log combined_deflate_proxypass_ssl "expr=(reqenv('forwarded') == 'yes' && reqenv('dontlog') != 'yes')"
        </IfModule>
    </IfModule>
</VirtualHost>
 
<VirtualHost *:443>
    ServerAdmin webmaster@tachtler.net
    ServerName postfixadmin.tachtler.net
    ServerPath /
 
    # ----------------------------------------------------------
    # SSL settings
    # ----------------------------------------------------------
    <IfModule ssl_module>
        SSLEngine On
        SSLCertificateFile /etc/letsencrypt/live/tachtler.net/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/tachtler.net/privkey.pem
 
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory "/srv/http/cgi-bin">
            SSLOptions +StdEnvVars
        </Directory>
 
        BrowserMatch "MSIE [2-5]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    </IfModule>
 
    # ----------------------------------------------------------
    # Rewrite settings
    # Rewrite the requestet URI - PERMANENT - to HTTPS and leave
    # this virtual Host to the HTTPS variant of it.
    # ----------------------------------------------------------
    <IfModule rewrite_module>
        RewriteEngine On
        RewriteCond "%{HTTPS}" "!=on"
        RewriteRule "^(.*)$" "https://%{HTTP_HOST}%{REQUEST_URI}" [R=301,L]
    </IfModule>
 
    # ----------------------------------------------------------
    # Alias settings - The "/" must be at the end!
    # ----------------------------------------------------------
    <IfModule alias_module>
        Alias / "/usr/share/webapps/postfixadmin/public/"
    </IfModule>
 
    # ----------------------------------------------------------
    # Directory access settings
    # URL of https://servername/
    # ----------------------------------------------------------
    <Directory "/usr/share/webapps/postfixadmin/public">
        DirectoryIndex index.php
        Options +Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
 
        <FilesMatch \.php$>
            SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost"
        </FilesMatch>
 
    </Directory>
 
    # ----------------------------------------------------------
    # Logging settings
    # ----------------------------------------------------------
    <IfModule log_config_module>
        ErrorLog /var/log/httpd/postfixadmin.tachtler.net_error.log
        SetEnvIf Request_URI "^/tunnel" forwarded
        SetEnvIF User-Agent "HAProxy" dontlog=yes
        SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded=yes
        <IfModule logio_module>
            CustomLog /var/log/httpd/postfixadmin.tachtler.net_access.log combined_deflate_ssl "expr=(reqenv('forwarded') != 'yes' && reqenv('dontlog') != 'yes')"
            CustomLog /var/log/httpd/postfixadmin.tachtler.net_access.log combined_deflate_proxypass_ssl "expr=(reqenv('forwarded') == 'yes' && reqenv('dontlog') != 'yes')"
        </IfModule>
    </IfModule>
</VirtualHost> 

Apache Webserver: /etc/httpd/conf/httpd.conf

Damit die zuvor unter

neu erstellte Konfigurationsdatei auch durch den Apache HTTPD Webserver eingelesen wird, ist nachfolgende Ergänzung in der bereits bestehenden Konfigurationsdatei

  • /etc/httpd/conf/httpd.conf

wie folgt am Ende der Konfigurationsdatei hinzuzufügen:

# Load *.conf files in the "conf/vhost" directory, if any.
IncludeOptional conf/vhost/*.conf  

Apache Webserver: Neustart

Nach Durchführung der vorhergehenden Konfigurationsschritte, sollte einem Neustart nichts im Wege stehen und die Apache VHOST-Konfiguration angezogen werden:

# systemctl restart httpd.service

:!: HINWEIS - Es erfolgen keine weiteren Ausgaben, wenn der Start erfolgreich war !

Konfiguration: postfixadmin

/etc/php/php-fpm.d/www.conf

:!: WICHTIG - Wie bereits bei den Voraussetzungen erwänt, ist es erforderlich eine

durchgeführ zu haben.

:!: HINWEIS - Diese muss nun wie folgt noch angepasst werden!

Diese Konfigurationsdatei erstellt einen Pool, welcher später für den Dienst/Daemon die einzelnen „Child-Threats“ startet, welche dann letztendlich die Anfragen vom Apache HTTP Server entgegennehmen und ausführen.

Die Änderungen an dieser Konfigurationsdatei sind davon abhängig, welches Verfahren zur Kommunikation mit PHP-FPM zum Einsatz kommen soll.

  • TCP/IP-Port
  • UNIX-Socket

Nachfolgende Änderungen sind an dieser Konfigurationsdatei durchzuführen:

(Komplette Konfigurationsdatei)

/etc/php/php-fpm.d/www.conf

Erläuterungen zu den Änderungen

  • user = postfixadmin

Es muss der Benutzer auf postfixadmin abgeändert werden.

  • group = postfixadmin

Es muss die Gruppe auf postfixadmin abgeändert werden.

  • pm.status_path = /php-fpm-status

Aktivieren der Statusseite durch setzen des Pfades für den Aufruf!

  • pm.status_listen = /run/php-fpm/php-fpm-status.sock

Konfiguration des UNIX_Sockets auf dem die PHP-FPM-Status Informationen abgerufen werden können.

:!: WICHTIG - Es muss ein eigener UNIX-Socket definiert werden!

/etc/php/php.ini

Nachfolgende Konfigurationen sind in der Konfigurationsdatei

  • /etc/php/php.ini

ebenfalls durchzuführen, damit eine Verbindung zur MariaDB-Datenbank möglich ist.

(Nur relevanter Ausschnitt)

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
 
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and
; 'extension='php_<ext>.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=<ext>) syntax.
;
;extension=bcmath
;extension=bz2
;extension=calendar
extension=curl
;extension=dba
;extension=enchant
;extension=exif
;extension=ffi
;extension=ftp
;extension=gd
;extension=gettext
;extension=gmp
;extension=iconv
;extension=intl
;extension=ldap
;Tachtler
 default: extension=mysqli
extension=mysqli
;extension=odbc
;zend_extension=opcache
;extension=pdo_dblib
 Tachtler
;default: extension=pdo_mysql
extension=pdo_mysql
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=pspell
;extension=shmop
;extension=snmp
;extension=soap
;extension=sockets
;extension=sodium
;extension=sqlite3
;extension=sysvmsg
;extension=sysvsem
;extension=sysvshm
;extension=tidy
;extension=xsl
extension=zip

Nachfolgende Anpassungen wurden zusätzlich noch durchgeführt:

Extension: mysqli

  • ;Tachtler
    ; default: ;extension=mysqli
    extension=mysqli

Aktivierung der Verwendung der Erweiterung (extension) - mysqli.

Extension: pdo_mysql

  • ;Tachtler
    ; default: ;extension=pdo_mysql
    extension=pdo_mysql

Aktivierung der Verwendung der Erweiterung (extension) - pdo_mysql.

postfixadmin: php-fpm.service - Neustart

Nach Durchführung der vorhergehenden Konfigurationsschritte, sollte einem Neustart nichts im Wege stehen und die php-fpm-Konfiguration angezogen werden:

# systemctl restart php-fpm.service

:!: HINWEIS - Es erfolgen keine weiteren Ausgaben, wenn der Start erfolgreich war !

postfixadmin: Aufruf Web-Anwendung

Nachfolgend kann zu jetzigen Zeitpunkt unter Verwendung eines Browsers die Web-Anwendung wie folgt aufgerufen werden:

und sollte eine Ausgabe im Browser in etwa wie nachfolgende Bildschirmkopie zeigt, zur Anzeige bringen:

PostfixAdmin - Willkommens Seite

/etc/webapps/postfixadmin/config.local.php

Nachfolgende Konfigurationsdatei

  • /etc/webapps/postfixadmin/config.inc.php

enthält die standard Konfigurationseinstellungen von PostfixAdmin.

Die zu verwendende Konfigurationsdatei sollte jedoch

  • /etc/webapps/postfixadmin/config.local.php

sein - Änderungen sollten NUR hier erfolgen!

:!: WICHTIG - Bei einem UPDATE von PostfixAdmin, werden die persönlichen Konfigurationen, so NICHT überschrieben !!!

Nachfolgende Anpassungen an der Konfigurationsdatei

  • /var/www/postfixadmin/config.local.php

sind als Beispiel gedacht:

<?php
/*****************************************************************
 *  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 * You have to set $CONF['configured'] = true; before the
 * application will run!
 * Doing this implies you have changed this file as required.
 * i.e. configuring database etc; specifying setup.php password etc.
 */
$CONF['configured'] = false;
 
// In order to setup Postfixadmin, you MUST specify a hashed password here.
// To create the hash, visit setup.php in a browser and type a password into the field,
// on submission it will be echoed out to you as a hashed value.
$CONF['setup_password'] = 'changeme';
 
// Language config
// Language files are located in './languages', change as required..
$CONF['default_language'] = 'de';
 
// Database Config
// mysqli = MySQL 4.1+ or MariaDB
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'db.idmz.tachtler.net';
$CONF['database_user'] = 'postfixuser';
$CONF['database_password'] = 'geheim';
$CONF['database_name'] = 'postfix';
 
// Site Admin
// Define the Site Admin's email address below.
// This will be used to send emails from to create mailboxes and
// from Send Email / Broadcast message pages.
// Leave blank to send email from the logged-in Admin's Email address.
$CONF['admin_email'] = 'postmaster@tachtler.net';
 
// Encrypt
// In what way do you want the passwords to be crypted?
//
// md5crypt = internal postfix admin md5
// md5 = md5 sum of the password
// system = whatever you have set as your PHP system default
// cleartext = clear text passwords (ouch!)
// mysql_encrypt = useful for PAM integration
// authlib = support for courier-authlib style passwords - also set $CONF['authlib_default_flavor']
//
// dovecot:CRYPT-METHOD = use dovecotpw -s 'CRYPT-METHOD'. Example: dovecot:CRAM-MD5
//    IMPORTANT:
//    - don't use dovecot:* methods that include the username in the hash - you won't be able to login to PostfixAdmin in this case
//    - you'll need at least dovecot 2.1 for salted passwords ('doveadm pw' 2.0.x doesn't support the '-t' option)
//    - dovecot 2.0.0 - 2.0.7 is not supported
//
// php_crypt:CRYPT-METHOD:DIFFICULTY:PREFIX = use PHP built in crypt()-function. Example: php_crypt:SHA512:50000
// - php_crypt CRYPT-METHOD: Supported values are DES, MD5, BLOWFISH, SHA256, SHA512
// - php_crypt DIFFICULTY: Larger value is more secure, but uses more CPU and time for each login.
// - php_crypt DIFFICULTY: Set this according to your CPU processing power.
// - php_crypt DIFFICULTY: Supported values are BLOWFISH:4-31, SHA256:1000-999999999, SHA512:1000-999999999
// - php_crypt DIFFICULTY: leave empty to use default values (BLOWFISH:10, SHA256:5000, SHA512:5000). Example: php_crypt:SHA512
// - php_crypt PREFIX: hash has specified prefix - example: php_crypt:SHA512::{SHA512-CRYPT}
//
// sha512.b64 - {SHA512-CRYPT.B64} (base64 encoded sha512) (no dovecot dependency; should support migration from md5crypt)
$CONF['encrypt'] = 'php_crypt:SHA512:50000';
// OR - with dovecot as SALS backend
// $CONF['encrypt'] = 'cleartext';
 
// Password validation
// New/changed passwords will be validated using all regular expressions in the array.
// If a password doesn't match one of the regular expressions, the corresponding
// error message from $PALANG (see languages/*.lang) will be displayed.
// See http://de3.php.net/manual/en/reference.pcre.pattern.syntax.php for details
// about the regular expression syntax.
// If you need custom error messages, you can add them using $CONF['language_hook'].
// If a $PALANG text contains a %s, you can add its value after the $PALANG key
// (separated with a space).
$CONF['password_validation'] = array(
#    '/regular expression/' => '$PALANG key (optional: + parameter)',
    '/.{8}/'                => 'password_too_short 8',      # minimum length 8 characters
    '/([a-zA-Z].*){3}/'     => 'password_no_characters 3',  # must contain at least 3 characters
    '/([0-9].*){2}/'        => 'password_no_digits 2',      # must contain at least 2 digits

    /*  support a 'callable' value which if it returns a non-empty string will be assumed to have failed, non-empty string should be a PALANG key */
    // 'length_check'          => function($password) { if (strlen(trim($password)) < 3) { return 'password_too_short'; } },
);
 
// Generate Password
// Generate a random password for a mailbox or admin and display it.
// If you want to automagically generate passwords set this to 'YES'.
$CONF['generate_password'] = 'YES';
 
// Page Size
// Set the number of entries that you would like to see
// in one page.
$CONF['page_size'] = '25';
 
// Default Aliases
// The default aliases that need to be created for all domains.
// You can specify the target address in two ways:
// a) a full mail address
// b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain
$CONF['default_aliases'] = array (
    'abuse' => 'abuse@tachtler.net',
    'hostmaster' => 'hostmaster@tachtler.net',
    'postmaster' => 'postmaster@tachtler.net',
    'webmaster' => 'webmaster@tachtler.net'
);
 
// Default Domain Values
// Specify your default values below. Quota in MB.
$CONF['aliases'] = '0';
$CONF['mailboxes'] = '0';
$CONF['maxquota'] = '1000';
$CONF['domain_quota_default'] = '5120';
 
// Quota
// When you want to enforce quota for your mailbox users set this to 'YES'.
$CONF['quota'] = 'YES';
// If you want to enforce domain-level quotas set this to 'YES'.
$CONF['domain_quota'] = 'NO';
// You can either use '1024000' or '1048576'
$CONF['quota_multiplier'] = '1024000';
// fill state threshold (in per cent) for medium level (displayed as orange)
$CONF['quota_level_med_pct'] = 80;
// fill state threshold (in per cent) for high level (displayed as red)
$CONF['quota_level_high_pct'] = 90;
 
// Transport
// If you want to define additional transport options for a domain set this to 'YES'.
// Read the transport file of the Postfix documentation.
$CONF['transport'] = 'YES';
// Transport options
// If you want to define additional transport options put them in array below.
$CONF['transport_options'] = array (
    'virtual',  // for virtual accounts
    'local',    // for system accounts
    'relay'     // for backup mx
);
// Transport default
// You should define default transport. It must be in array above.
$CONF['transport_default'] = 'virtual';
 
//
//
// Virtual Vacation Stuff
//
//
 
// If you want to use virtual vacation for you mailbox users set this to 'YES'.
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
$CONF['vacation'] = 'NO';
 
// This is the autoreply domain that you will need to set in your Postfix
// transport maps to handle virtual vacations. It does not need to be a
// real domain (i.e. you don't need to setup DNS for it).
// This domain must exclusively be used for vacation. Do NOT use it for "normal" mail addresses.
$CONF['vacation_domain'] = 'autoreply.tachtler.net';
 
// Vacation Control
// If you want users to take control of vacation set this to 'YES'.
$CONF['vacation_control'] ='NO';
 
// Vacation Control for admins
// Set to 'YES' if your domain admins should be able to edit user vacation.
$CONF['vacation_control_admin'] = 'NO';
 
// ReplyType options
// If you want to define additional reply options put them in array below.
// The array has the format   seconds between replies => $PALANG text
// Special values for seconds are: 
// 0 => only reply to the first mail while on vacation 
// 1 => reply on every mail
$CONF['vacation_choice_of_reply'] = array (
   0 => 'reply_once',        // Sends only Once the message during Out of Office
   # considered annoying - only send a reply on every mail if you really need it
   # 1 => 'reply_every_mail',       // Reply on every email
   60*60 *24*7 => 'reply_once_per_week'        // Reply if last autoreply was at least a week ago
);
 
//
// End Vacation Stuff.
//
 
// Fetchmail
// If you don't want fetchmail tab set this to 'NO';
$CONF['fetchmail'] = 'NO';
 
// Header
$CONF['show_header_text'] = 'YES';
$CONF['header_text'] = ':@: mx1.tachtler.net ::'';
 
// Footer
// Below information will be on all pages.
// If you don't want the footer information to appear set this to 'NO'.
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Zurück zu postfixadmin.tachtler.net';
$CONF['footer_link'] = 'https://postfixadmin.tachtler.net/main.php';
 
// Welcome Message
// This message is send to every newly created mailbox.
// Change the text between EOM.
$CONF['welcome_text'] = <<<EOM
Herzlich Willkommen auf dem Mailserver von tachtler.net!
 
Bei Problemen, Fragen und/oder Anregungen zu diesem Dienst,
bitte senden Sie einfach eine e-Mail an
 
    postmaster@tachtler.net
 
Der Webmail-Dienst ist unter der Adresse (URL/Link):
 
    https://buero.tachtler.net
 
zu erreichen.
 
Vielen Dank!
EOM;
 
// When creating mailboxes or aliases, check that the domain-part of the
// address is legal by performing a name server look-up.
$CONF['emailcheck_resolve_domain']='YES';
 
// mails to these domains will never be flagged as undeliverable
$CONF['show_undeliverable_exceptions']=array("");
 
// you can assign special colors to some domains. To do this,
// - add the domain to show_custom_domains
// - add the corresponding color to show_custom_colors
$CONF['show_custom_domains']=array("tachtler.net");
$CONF['show_custom_colors']=array("lightblue");
// If you use a recipient_delimiter in your postfix config, you can also honor it when aliases are checked.
// Example: $CONF['recipient_delimiter'] = "+";
// Set to "" to disable this check.
$CONF['recipient_delimiter'] = "+";
 
// Optional:
// Sub-folders which should automatically be created for new users.
// The sub-folders will also be subscribed to automatically.
// Will only work with IMAP server which implement sub-folders.
// Will not work with POP3.
// If you define create_mailbox_subdirs, then the
// create_mailbox_subdirs_host must also be defined.
// Note: requires imap extension within PHP
// $CONF['create_mailbox_subdirs']=array('Spam');
$CONF['create_mailbox_subdirs'] = array();
$CONF['create_mailbox_subdirs_host']='';
//
// Specify '' for Dovecot and 'INBOX.' for Courier.
$CONF['create_mailbox_subdirs_prefix']='';
 
// Optional:
// Show used quotas from Dovecot dictionary backend in virtual
// mailbox listing.
// See: DOCUMENTATION/DOVECOT.txt
//      http://wiki.dovecot.org/Quota/Dict
//
$CONF['used_quotas'] = 'NO';
 
//Account expiration info
//If enabled, mailbox passwords have a password_expiry field set, which is updated each time the password is changed, based on the parent domain's   password_expiry (days) value.
//More details in README.password_expiration
$CONF['password_expiration'] = 'NO';

Konfiguration: Authentifizierungsmethoden - cram-md5/digest-md5

:!: ACHTUNG - Falls Dovecot als Authentifizierungs backend z.B. für eine SASL-Authentifizierung zum Einsatz kommen soll, ist es erforderlich das Passwort im Klartext in der Datenbank zu speichern!
// OR - with dovecot as SALS backend
$CONF['encrypt'] = 'cleartext';

Siehe auch den nachfolgender internen Link

Aktuell ist das Abhören der Übertragung des Benutzernamens und des Passwortes nahezu unmöglich, da bei der Übertragung ein individueller Sitzungsschlüssel zum Einsatz kommt. Mit Hilfe dieses individuellen Sitzungsschlüssels, können Server und Client, jeweils für sich das Passwort berechnen, der ebenfalls nur jeweils einmalig für eine Sitzung identisch ist.

:!: WICHITG - Da Server und Client jeweils das Passwort errechnen können müssen, ist es

  • erforderlich, das Server und Client, das Passwort im Klartext kennen!

:!: HINWEIS - Das bedeutet, dass beim Einsatz von cram-md5/digest-md5 das

  • Passwort des Benutzers im Klartext gespeichert werden muss!

psotfixadmin: Setup Web-Anwendung

Nachfolgend kann zu jetzigen Zeitpunkt unter Verwendung eines Browsers die Web-Anwendung wie folgt aufgerufen werden:

und sollte eine Ausgabe im Browser in etwa wie nachfolgende Bildschirmkopie zeigt, zur Anzeige bringen:

PostfixAdmin - setup.php

Anschliessend kann nun ein setup_passwort hash erstellt werden, welcher dann als kryptischer Wert am Bildschirm angezeigt wird. Dies wird durch die Eingabe eine Passwortes und dessen Wiederholung und durch drücken der Schaltfläche [Generate setup_password hash] mit der linken Maustaste durchgeführt.

PostfixAdmin - setup.php - setup_password hash

Dieser kryptische Wert muss dann in die Konfigurationsdatei

  • /etc/webapps/postfixadmin/config.local.php

hinein kopiert werden,

# vim /etc/webapps/postfixadmin/config.local.php

(Nur relevanter Ausschnitt)

  • // In order to setup Postfixadmin, you MUST specify a hashed password here.
    // To create the hash, visit setup.php in a browser and type a password into the field,
    // on submission it will be echoed out to you as a hashed value.
    // Tachtler:
    // default: $CONF['setup_password'] = 'changeme';
    $CONF['setup_password'] = '$2y$10$D6qhxU29/k4SRjjxibDglOxI1JUMM5CElmU43VNFLDvMpb5Efj5b6';

um mit der Konfiguration weiter fort fahren zu können, MUSS nun die Seite im Browser - NEU geladen werden. Die kann z.B. durch drücken der Schaltfläche [Aktualisieren] in der Schaltflächenleiste des Browsers erfolgen, wie nachfolgend dargestellte Bildschrimausgabe zeigt.

Hier ist es nun erforderlich

  1. das zuvor gesetzte Passwort im Feld Setup password einzugeben
  2. im Feld Admin, kann nun der Benutzername des Administrators festgelegt werden
  3. in den Feldern Passwort und Passwort (nochmal) muss nun das Passwort des Administrators gesetzt werden.

PostfixAdmin - setup.php - Configure and Setup Postifadmin

Abschliessend ist dann zur Ausführung die Schaltfläche [Admin hinzufügen] mit der linken Maustaste zu drücken, was nachfolgende Ergänzung des bereits zuvor angezeigten Bildschirms zum Vorschein bringt:

PostfixAdmin - setup.php - Configure and Setup Postifadmin - druchgeführt

Jetzt muss noch in der Konfigurationsdatei

  • /etc/webapps/postfixadmin/config.local.php

nachfolgende Änderung nach erfolgreicher Konfiguration durchgeführt werden,

# vim /etc/webapps/postfixadmin/config.local.php

(Nur relevanter Ausschnitt)

/*****************************************************************
 *  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 * You have to set $CONF['configured'] = true; before the
 * application will run!
 * Doing this implies you have changed this file as required.
 * i.e. configuring database etc; specifying setup.php password etc.
 */
$CONF['configured'] = true;

Nachfolgend kann jetzt unter Verwendung eines Browsers die Web-Anwendung wie folgt aufgerufen werden:

und sollte eine Ausgabe im Browser in etwa wie nachfolgende Bildschirmkopie zeigt zur Anzeige bringen:

PostfixAdmin - login.php

Nach erfolgreicher Anmeldung als Administrator, sollte eine Bildschirm in etwas wie nachfolgenderangezeigt werden:

PostfixAdmin - main.php

Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
tachtler/postfixadmin_archlinux.txt · Zuletzt geändert: 2024/12/25 10:57 von klaus