mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.58k stars 1.15k forks source link

Compatibility with existing nginx container running on different ports #4055

Closed allanext closed 3 years ago

allanext commented 3 years ago

Prior to placing the issue, please check following: (fill out each checkbox with an X once done)

Summary

I'm trying to install mailcow on a server running also another nginx that takes care of web containers but there's an issue and I'm not sure if it's a bug, a configuration issue or the project requires to run on a separate machine.

The error that I get is:

php-fpm-mailcow_1    | Waiting for SQL...
sogo-mailcow_1       | Waiting for database to come up...
clamd-mailcow_1      | Tue Apr 13 14:52:03 2021 -> Database test passed.
clamd-mailcow_1      | Tue Apr 13 14:52:03 2021 -> daily.cvd updated (version: 26139, sigs: 3970302, f-level: 63, builder: raynman)
clamd-mailcow_1      | Tue Apr 13 14:52:03 2021 -> main database available for download (remote version: 59)
dovecot-mailcow_1    | Waiting for database to come up...
ejabberd-mailcow_1   | Waiting for PHP on port 9001...
postfix-mailcow_1    | Waiting for database to come up...
php-fpm-mailcow_1    | Waiting for SQL...
sogo-mailcow_1       | Waiting for database to come up...
dovecot-mailcow_1    | Waiting for database to come up...
rspamd-mailcow_1     | Waiting for PHP on port 9001...
clamd-mailcow_1      | Tue Apr 13 14:52:06 2021 -> Testing database: '/var/lib/clamav/tmp.e99bdb0425/clamav-c38ae99bd194f3a87e2a6b07b3b0f3b6.tmp-main.cvd' ...
postfix-mailcow_1    | Waiting for database to come up...
php-fpm-mailcow_1    | Waiting for SQL...
sogo-mailcow_1       | Waiting for database to come up...

These are the other containers running (see ports mappings, related to port 80 and 443):

[ec2-user@ip-172-16-1-36 ~]$ docker ps
CONTAINER ID        IMAGE                                           COMMAND                  CREATED             STATUS              PORTS                                              NAMES
74f23fea404f        nginx:stable-alpine                             "/docker-entrypoint.…"   4 days ago          Up 4 days           172.16.1.36:80->80/tcp, 172.16.1.36:443->443/tcp   nginx-web
af053911418d        jrcs/letsencrypt-nginx-proxy-companion:stable   "/bin/bash /app/entr…"   4 days ago          Up 4 days                                                              nginx-letsencrypt
70d6da859eae        jwilder/docker-gen                              "/usr/local/bin/dock…"   4 days ago          Up 4 days                                                              nginx-gen
bdb5f2bb2bd6        wordpress:latest                                "docker-entrypoint.s…"   13 days ago         Up 4 days           80/tcp, 443/tcp                                    domain2-wp
a32da61eba13        mariadb:latest                                  "docker-entrypoint.s…"   13 days ago         Up 4 days           3306/tcp                                           domain2-db
3f88159e3455        drupal:7.78-php7.4-apache-buster                "docker-php-entrypoi…"   2 weeks ago         Up 4 days           80/tcp, 443/tcp                                    domain1-app1
ca4f1cd38e9a        drupal:7.78-php7.4-apache-buster                "docker-php-entrypoi…"   2 weeks ago         Up 4 days           80/tcp, 443/tcp                                    domain1-drupal
b40ff437af96        mariadb:latest                                  "docker-entrypoint.s…"   2 weeks ago         Up 4 days           3306/tcp                                           domain1-db

And these are the original routes/bridges:

[ec2-user@ip-172-16-1-36 ~]$ ip route
default via 172.16.1.1 dev eth0 
169.254.169.254 dev eth0 
172.16.1.0/24 dev eth0 proto kernel scope link src 172.16.1.36 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
172.22.0.0/16 dev br-4acfcb6d653e proto kernel scope link src 172.22.0.1 
172.26.0.0/16 dev br-2f0d188f8a69 proto kernel scope link src 172.26.0.1 
192.168.144.0/20 dev br-15da9f06f9e1 proto kernel scope link src 192.168.144.1 

I've modified the following on mailcow.conf:

HTTP_PORT=8080
HTTP_BIND=172.16.1.36
HTTPS_PORT=8443
HTTPS_BIND=172.16.1.36
IPV4_NETWORK=172.23.1  # To avoid conflict with existing network (see ip route above)
IPV6_NETWORK=fd4d:6169:6c63:6f77::/64 # Kept the same, is this ok ????

Am I making a mistake or there's an issue with the existing nginx/web containers?

DNS seems working fine.

Question Answer
My operating system Amazon linux 2
Is Apparmor, SELinux or similar active? SELinux status: disabled
Virtualization technlogy (KVM, VMware, Xen, etc - LXC and OpenVZ are not supported KVM
Server/VM specifications (Memory, CPU Cores) 2 Cores / 8GB RAM
Docker Version (docker version) 19.03.13-ce
Docker-Compose Version (docker-compose version) 1.29.0
Reverse proxy (custom solution) Other nginx but running on different ports / subnet
allanext commented 3 years ago

The logs of the database don't show any errors, just a warning:

[ec2-user@ip-172-16-1-36 ~]$ docker logs mailcow_mysql-mailcow_1
2021-04-16 09:54:14-05:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.9+maria~focal started.
2021-04-16 09:54:15-05:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-16 09:54:15-05:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.9+maria~focal started.
2021-04-16  9:54:15 0 [Note] mysqld (mysqld 10.5.9-MariaDB-1:10.5.9+maria~focal) starting as process 1 ...
2021-04-16  9:54:15 0 [Note] InnoDB: Uses event mutexes
2021-04-16  9:54:15 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-04-16  9:54:15 0 [Note] InnoDB: Number of pools: 1
2021-04-16  9:54:15 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2021-04-16  9:54:15 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2021-04-16  9:54:15 0 [Note] InnoDB: Using Linux native AIO
2021-04-16  9:54:15 0 [Note] InnoDB: Initializing buffer pool, total size = 25165824, chunk size = 25165824
2021-04-16  9:54:15 0 [Note] InnoDB: Completed initialization of buffer pool
2021-04-16  9:54:15 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-04-16  9:54:15 0 [Note] InnoDB: 128 rollback segments are active.
2021-04-16  9:54:15 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-04-16  9:54:15 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-04-16  9:54:15 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-04-16  9:54:15 0 [Note] InnoDB: 10.5.9 started; log sequence number 675603; transaction id 2133
2021-04-16  9:54:15 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-04-16  9:54:15 0 [Note] Server socket created on IP: '::'.
2021-04-16  9:54:15 0 [Warning] 'proxies_priv' entry '@% root@12bd00324b94' ignored in --skip-name-resolve mode.
2021-04-16  9:54:15 0 [Note] InnoDB: Buffer pool(s) load completed at 210416  9:54:15
2021-04-16  9:54:15 1 [Note] Event Scheduler: scheduler thread started with id 1
2021-04-16  9:54:15 0 [Note] mysqld: ready for connections.
Version: '10.5.9-MariaDB-1:10.5.9+maria~focal'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
allanext commented 3 years ago

I've stopped and removed the containers, deleted the git mailcow repository and downloaded the git repo again from the root user (made sure umask 0022).

sudo -s
chown -R root:ec2-user *
chown -R root:ec2-user .*
chmod -R g+rw *
chmod -R g+rw .*

then I've generated the configuration and changed:

HTTP_PORT=8080
HTTP_BIND=172.16.1.36
HTTPS_PORT=8443
HTTPS_BIND=172.16.1.36
ENABLE_SSL_SNI=y
IPV4_NETWORK=172.23.1

I've runned the ./update.sh script and then docker-compose up and i get:

sogo-mailcow_1 | ERROR 1146 (42S02) at line 1: Table 'mailcow.versions' doesn't exist

the full log is:

dovecot-mailcow_1    | Waiting for versions table to be created...
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/proxymap[359]: warning: mysql:/opt/postfix/conf/sql/mysql_virtual_alias_maps.cf: query failed: Table 'mailcow.alias' doesn't exist
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/proxymap[359]: warning: mysql:/opt/postfix/conf/sql/mysql_virtual_domains_maps.cf: query failed: Table 'mailcow.alias_domain' doesn't exist
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/proxymap[359]: warning: mysql:/opt/postfix/conf/sql/mysql_recipient_canonical_maps.cf: query failed: Table 'mailcow.recipient_maps' doesn't exist
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/trivial-rewrite[363]: warning: virtual_alias_domains: proxy:mysql:/opt/postfix/conf/sql/mysql_virtual_alias_maps.cf: table lookup problem
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/trivial-rewrite[363]: warning: virtual_alias_domains lookup failure
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/trivial-rewrite[363]: warning: virtual_alias_domains: proxy:mysql:/opt/postfix/conf/sql/mysql_virtual_alias_maps.cf: table lookup problem
postfix-mailcow_1    | Apr 16 10:36:50 5a1e02c9dfa7 postfix/trivial-rewrite[363]: warning: virtual_mailbox_domains: proxy:mysql:/opt/postfix/conf/sql/mysql_virtual_domains_maps.cf: table lookup problem
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 ACME health level: 100% (1/1), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Dovecot replication health level: 100% (20/20), health trend: 0
nginx-mailcow_1      | 172.23.1.3 - - [16/Apr/2021:15:36:50 +0000] "GET / HTTP/1.1" 200 15 "-" "check_http/v (nagios-plugins 2.2.1)"
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Redis health level: 100% (5/5), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Fail2ban health level: 100% (1/1), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Mail queue health level: 100% (20/20), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 MySQL/MariaDB health level: 100% (5/5), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 PHP-FPM health level: 20% (1/5), health trend: -4
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 SOGo health level: 33% (1/3), health trend: -2
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Nginx health level: 100% (5/5), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Olefy health level: 100% (5/5), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Clamd health level: 100% (15/15), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:50 EST 2021 Dovecot health level: 17% (2/12), health trend: -10
watchdog-mailcow_1   | Fri Apr 16 15:36:51 EST 2021 Unbound health level: 100% (5/5), health trend: 0
watchdog-mailcow_1   | Fri Apr 16 15:36:51 EST 2021 Rspamd health level: 80% (4/5), health trend: -1
watchdog-mailcow_1   | Fri Apr 16 15:36:51 EST 2021 Ratelimit health level: 100% (1/1), health trend: 0
dockerapi-mailcow_1  | 172.23.1.3 - - [16/Apr/2021 15:36:51] "GET /containers/json HTTP/1.1" 200 -
watchdog-mailcow_1   | Fri Apr 16 15:36:51 EST 2021 IPv6 NAT health level: 0% (0/1), health trend: -1
dockerapi-mailcow_1  | 172.23.1.9 - - [16/Apr/2021 15:36:51] "GET /containers/json HTTP/1.1" 200 -
postfix-mailcow_1    | Apr 16 10:36:52 5a1e02c9dfa7 postfix/master[354]: warning: process /usr/lib/postfix/sbin/smtpd pid 376 exit status 1
postfix-mailcow_1    | Apr 16 10:36:52 5a1e02c9dfa7 postfix/master[354]: warning: /usr/lib/postfix/sbin/smtpd: bad command startup -- throttling
watchdog-mailcow_1   | Fri Apr 16 15:36:52 EST 2021 Primary certificate expiry check health level: 29% (2/7), health trend: -5
sogo-mailcow_1       | Waiting for schema update...
sogo-mailcow_1       | ERROR 1146 (42S02) at line 1: Table 'mailcow.versions' doesn't exist
ejabberd-mailcow_1   | Waiting for PHP on port 9001...
rspamd-mailcow_1     | Waiting for PHP on port 9001...
dovecot-mailcow_1    | Waiting for versions table to be created...
dockerapi-mailcow_1  | 172.23.1.9 - - [16/Apr/2021 15:36:54] "GET /containers/json HTTP/1.1" 200 -
ejabberd-mailcow_1   | Waiting for PHP on port 9001...
dockerapi-mailcow_1  | 172.23.1.9 - - [16/Apr/2021 15:36:56] "GET /containers/json HTTP/1.1" 200 -
rspamd-mailcow_1     | Waiting for PHP on port 9001...
dovecot-mailcow_1    | Waiting for versions table to be created...
sogo-mailcow_1       | Waiting for schema update...
sogo-mailcow_1       | ERROR 1146 (42S02) at line 1: Table 'mailcow.versions' doesn't exist
ejabberd-mailcow_1   | Waiting for PHP on port 9001...

The web page is giving me:

🐄 - we are on our way.

502
Please do not stop the stack, while we are initializing the database or do other preparations.

What is happening? - Nginx cannot connect to an upstream server.
This is fine, if mailcow was just installed or updated and can take a few minutes to complete.
Please check the logs or contact support, if the error persists.

I've re-did everything without changing the permission for the ec2-user, changed the conf to:

HTTP_PORT=8080
HTTP_BIND=127.0.0.1
HTTPS_PORT=8443
HTTPS_BIND=127.0.0.1
ENABLE_SSL_SNI=y
IPV4_NETWORK=172.23.1
# IPV6_NETWORK=fd4d:6169:6c63:6f77::/64

and now i'm back to:

unbound-mailcow_1    | [1618588098] unbound[1:0] warning: setrlimit: Operation not permitted
unbound-mailcow_1    | [1618588098] unbound[1:0] warning: cannot increase max open fds from 1024 to 4152
unbound-mailcow_1    | [1618588098] unbound[1:0] warning: continuing with less udp ports: 972
unbound-mailcow_1    | [1618588098] unbound[1:0] warning: increase ulimit or decrease threads, ports in config to remove this warning
unbound-mailcow_1    | [1618588098] unbound[1:0] notice: init module 0: validator
unbound-mailcow_1    | [1618588098] unbound[1:0] notice: init module 1: iterator
unbound-mailcow_1    | [1618588098] unbound[1:0] info: start of service (unbound 1.13.0).
unbound-mailcow_1    | [1618588100] unbound[1:0] info: generate keytag query _ta-4f66. NULL IN
watchdog-mailcow_1   | Waiting for containers to settle...
rspamd-mailcow_1     | Waiting for PHP on port 9001...
postfix-mailcow_1    | Waiting for database to come up...
php-fpm-mailcow_1    | Waiting for SQL...
dovecot-mailcow_1    | Waiting for database to come up...
sogo-mailcow_1       | Waiting for database to come up...
postfix-mailcow_1    | Waiting for database to come up...
php-fpm-mailcow_1    | Waiting for SQL...
ejabberd-mailcow_1   | Waiting for PHP on port 9001...
rspamd-mailcow_1     | Waiting for PHP on port 9001...
dovecot-mailcow_1    | Waiting for database to come up...
sogo-mailcow_1       | Waiting for database to come up...
postfix-mailcow_1    | Waiting for database to come up...
php-fpm-mailcow_1    | Waiting for SQL...
clamd-mailcow_1      | Fri Apr 16 10:48:40 2021 -> Database test passed.
clamd-mailcow_1      | Fri Apr 16 10:48:40 2021 -> daily.cvd updated (version: 26142, sigs: 3971117, f-level: 63, builder: raynman)
clamd-mailcow_1      | Fri Apr 16 10:48:40 2021 -> main database available for download (remote version: 59)
dovecot-mailcow_1    | Waiting for database to come up...
sogo-mailcow_1       | Waiting for database to come up...
ejabberd-mailcow_1   | Waiting for PHP on port 9001...
rspamd-mailcow_1     | Waiting for PHP on port 9001..

any ideas? Thank you !

allanext commented 3 years ago

at the beginning of docker-compose up I'm noticing this "Invalid DNS reply. Falling back to HTTP mode":

clamd-mailcow_1      | Fri Apr 16 11:11:48 2021 -> ClamAV update process started at Fri Apr 16 11:11:48 2021
clamd-mailcow_1      | Fri Apr 16 11:11:58 2021 -> ^Can't query current.cvd.clamav.net
clamd-mailcow_1      | Fri Apr 16 11:11:58 2021 -> ^Invalid DNS reply. Falling back to HTTP mode.
dockerapi-mailcow_1  |  * Running on https://0.0.0.0:443/ (Press CTRL+C to quit)
dockerapi-mailcow_1  |  * Serving Flask app "dockerapi" (lazy loading)
dockerapi-mailcow_1  |  * Environment: production
dockerapi-mailcow_1  |    WARNING: This is a development server. Do not use it in a production deployment.
dockerapi-mailcow_1  |    Use a production WSGI server instead.
dockerapi-mailcow_1  |  * Debug mode: off
dovecot-mailcow_1    | Waiting for database to come up...
dovecot-mailcow_1    | Waiting for database to come up...
ejabberd-mailcow_1   | Waiting for PHP on port 9001..

I've also noticed that the mailcow nginx also opened port 80:

f3512fadeb43 nginx:mainline-alpine "/docker-entrypoint.…" 5 minutes ago Up 4 minutes 172.16.1.36:8080->8080/tcp, 80/tcp, 172.16.1.36:8443->8443/tcp mailcowdockerized_nginx-mailcow_1

is this the issue? as in conflicting with the other nginx (for other web apps) container running on 80 and 443 ?

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.