mailcow / mailcow-dockerized

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

Perpetual restarting of php-fpm-mailcow - UI does not load #3617

Closed sqlsolver closed 4 years ago

sqlsolver commented 4 years ago

Per PHP manual the -f switch is supposed to parse and execute the file. Instead, if you hit mail.cozyrentals.net it will immediately download it. This followed the 502 error described in the original issue and below.

I am having the same issue with perpetual restarting of php-fpm-mailcow. Executing directly as @stAn47 mentioned helps only temporarily (less than a minute before it goes down again). I cleared all containers as mentioned by @andryyy but this had no effect. From the logs, it looks like the db init may be failing.

From docker-entrypoint.sh:

  # Trigger db init
  echo "Running DB init..."
  php -c /usr/local/etc/php -f /web/inc/init_db.inc.php

  # Recreating domain map
  echo "Rebuilding domain map in Redis..."
  declare -a DOMAIN_ARR
    ${REDIS_CMDLINE} DEL DOMAIN_MAP > /dev/null
  while read line

Log showing php command options:

php-fpm-mailcow_1    | Cleaned up memcached
php-fpm-mailcow_1    | Rebuilding domain map in Redis...
php-fpm-mailcow_1    | Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]]
php-fpm-mailcow_1    |   -c <path>|<file> Look for php.ini file in this directory
php-fpm-mailcow_1    |   -n               No php.ini file will be used
php-fpm-mailcow_1    |   -d foo[=bar]     Define INI entry foo with value 'bar'
php-fpm-mailcow_1    |   -e               Generate extended information for debugger/profiler
php-fpm-mailcow_1    |   -h               This help
php-fpm-mailcow_1    |   -i               PHP information
php-fpm-mailcow_1    |   -m               Show compiled in modules
php-fpm-mailcow_1    |   -v               Version number
php-fpm-mailcow_1    |   -p, --prefix <dir>
php-fpm-mailcow_1    |                    Specify alternative prefix path to FastCGI process manager (default: /usr/local).
php-fpm-mailcow_1    |   -g, --pid <file>
php-fpm-mailcow_1    |                    Specify the PID file location.
php-fpm-mailcow_1    |   -y, --fpm-config <file>
php-fpm-mailcow_1    |                    Specify alternative path to FastCGI process manager config file.
php-fpm-mailcow_1    |   -t, --test       Test FPM configuration and exit
php-fpm-mailcow_1    |   -D, --daemonize  force to run in background, and ignore daemonize option from config file
php-fpm-mailcow_1    |   -F, --nodaemonize
php-fpm-mailcow_1    |                    force to stay in foreground, and ignore daemonize option from config file
php-fpm-mailcow_1    |   -O, --force-stderr
php-fpm-mailcow_1    |                    force output to stderr in nodaemonize even if stderr is not a TTY
php-fpm-mailcow_1    |   -R, --allow-to-run-as-root
php-fpm-mailcow_1    |                    Allow pool to run as root (disabled by default)

Originally posted by @sqlsolver in https://github.com/mailcow/mailcow-dockerized/issues/2582#issuecomment-647303866

sqlsolver commented 4 years ago

@andryyy do you have an idea as to the cause before you close? Mailcow is not mooing at all...

Adorfer commented 4 years ago

@sqlsolver

do you have an idea as to the cause before you close? Mailcow is not mooing at all...

suggestion: Just have a look into the template you explicitly decided not to use/to delete while submitting your issue.

sqlsolver commented 4 years ago

Never 'explicity decided.' Github offered the option to create a new issue with my comment on #2582 and when accepting that your template never pops up. GTK that it's better to create the issue directly for this repo and others.

andryyy commented 4 years ago

That's interesting. :) Thanks.

gsugambit commented 3 years ago

I'm having this same exact problem on a fresh install in ubuntu 20 with latest docker and docker-compose. Only files i changed are putting the nginx on another docker network and running it on http port 9998 https port 9999 since I have haproxy routing all traffic to my different compose containers.

This is the php image that was pulled mailcowdockerized_php-fpm-mailcow_1 mailcow/phpfpm 1.69 810ea1bc82ac 342.1 MB

This matches your last tag on: https://hub.docker.com/r/mailcow/phpfpm/tags?page=1&ordering=last_updated So i don't think this is an issue of the wrong container or anything.

@andryyy I'm noticing there hadn't been a new container in like 5 months. Could there be some issue with the new container?

Every container is running except the php one

root@ubuntu-openpcm:/opt/mailcow-dockerized# docker-compose ps
                Name                               Command                 State                                                              Ports                                                        
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mailcowdockerized_acme-mailcow_1        /sbin/tini -g -- /srv/acme.sh    Up                                                                                                                                
mailcowdockerized_clamd-mailcow_1       /sbin/tini -g -- /clamd.sh       Up                                                                                                                                
mailcowdockerized_dockerapi-mailcow_1   python3 -u /app/dockerapi.py     Up                                                                                                                                
mailcowdockerized_dovecot-mailcow_1     /docker-entrypoint.sh /bin ...   Up           0.0.0.0:110->110/tcp, 127.0.0.1:19991->12345/tcp, 0.0.0.0:143->143/tcp, 0.0.0.0:4190->4190/tcp, 0.0.0.0:993->993/tcp,
                                                                                      0.0.0.0:995->995/tcp                                                                                                 
mailcowdockerized_ipv6nat-mailcow_1     /docker-ipv6nat-compat --retry   Up                                                                                                                                
mailcowdockerized_memcached-mailcow_1   docker-entrypoint.sh memcached   Up           11211/tcp                                                                                                            
mailcowdockerized_mysql-mailcow_1       docker-entrypoint.sh mysqld      Up           127.0.0.1:13306->3306/tcp                                                                                            
mailcowdockerized_netfilter-mailcow_1   python3 -u /server.py            Up                                                                                                                                
mailcowdockerized_nginx-mailcow_1       /docker-entrypoint.sh /bin ...   Up           80/tcp, 0.0.0.0:9998->9998/tcp, 0.0.0.0:9999->9999/tcp                                                               
mailcowdockerized_olefy-mailcow_1       python3 -u /app/olefy.py         Up                                                                                                                                
mailcowdockerized_php-fpm-mailcow_1     /docker-entrypoint.sh php- ...   Restarting                                                                                                                        
mailcowdockerized_postfix-mailcow_1     /docker-entrypoint.sh /bin ...   Up           0.0.0.0:25->25/tcp, 0.0.0.0:465->465/tcp, 0.0.0.0:587->587/tcp, 588/tcp                                              
mailcowdockerized_redis-mailcow_1       docker-entrypoint.sh redis ...   Up           127.0.0.1:7654->6379/tcp                                                                                             
mailcowdockerized_rspamd-mailcow_1      /docker-entrypoint.sh /usr ...   Up                                                                                                                                
mailcowdockerized_sogo-mailcow_1        /docker-entrypoint.sh /bin ...   Up                                                                                                                                
mailcowdockerized_solr-mailcow_1        docker-entrypoint.sh /solr.sh    Up           127.0.0.1:18983->8983/tcp                                                                                            
mailcowdockerized_unbound-mailcow_1     /docker-entrypoint.sh /usr ...   Up           53/tcp, 53/udp                                                                                                       
mailcowdockerized_watchdog-mailcow_1    /bin/sh -c /watchdog.sh 2> ...   Up 
andryyy commented 3 years ago

The "only change" you made is very crucial. :) There will be the problem.

I updated the image yesterday (no version change, just updated the packages).

Nobody can help you without logs though. Logs and a git diff may help.

gsugambit commented 3 years ago

@andryyy

Here is the error log

hp-fpm-mailcow_1 | SQL upgrade iteration #1 php-fpm-mailcow_1 | MySQL is up-to-date - debug output: php-fpm-mailcow_1 | {"msg":"mysql_upgrade: already upgraded","text":"This installation of MariaDB is already upgraded to 10.4.17-MariaDB, use --force if you still need to run mysql_upgrade\n","type":"success"} php-fpm-mailcow_1 | We are master, preparing... php-fpm-mailcow_1 | Running DB init... php-fpm-mailcow_1 | Fixed _sogo_static_view php-fpm-mailcow_1 | Cleaned up memcached php-fpm-mailcow_1 | Rebuilding domain map in Redis... php-fpm-mailcow_1 | Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p ] [-g ] [-c ] [-d foo[=bar]] [-y ] [-D] [-F [-O]] php-fpm-mailcow_1 | -c | Look for php.ini file in this directory php-fpm-mailcow_1 | -n No php.ini file will be used php-fpm-mailcow_1 | -d foo[=bar] Define INI entry foo with value 'bar' php-fpm-mailcow_1 | -e Generate extended information for debugger/profiler php-fpm-mailcow_1 | -h This help php-fpm-mailcow_1 | -i PHP information php-fpm-mailcow_1 | -m Show compiled in modules php-fpm-mailcow_1 | -v Version number php-fpm-mailcow_1 | -p, --prefix

php-fpm-mailcow_1 | Specify alternative prefix path to FastCGI process manager (default: /usr/local). php-fpm-mailcow_1 | -g, --pid php-fpm-mailcow_1 | Specify the PID file location. php-fpm-mailcow_1 | -y, --fpm-config php-fpm-mailcow_1 | Specify alternative path to FastCGI process manager config file. php-fpm-mailcow_1 | -t, --test Test FPM configuration and exit php-fpm-mailcow_1 | -D, --daemonize force to run in background, and ignore daemonize option from config file php-fpm-mailcow_1 | -F, --nodaemonize php-fpm-mailcow_1 | force to stay in foreground, and ignore daemonize option from config file php-fpm-mailcow_1 | -O, --force-stderr php-fpm-mailcow_1 | force output to stderr in nodaemonize even if stderr is not a TTY php-fpm-mailcow_1 | -R, --allow-to-run-as-root php-fpm-mailcow_1 | Allow pool to run as root (disabled by default)

Here is the git diff. I'm omitting the change to the two cert files but here is the docker-compose changes

root@ubuntu-openpcm:/opt/mailcow-dockerized# git diff --name-only data/assets/ssl-example/cert.pem data/assets/ssl-example/key.pem data/conf/postfix/main.cf docker-compose.yml

 diff --git a/docker-compose.yml b/docker-compose.yml
index 9de2c6c4..213839f4 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -288,6 +288,9 @@ services:
         mailcow-network:
           aliases:
             - postfix
+        gsugambit-systems:
+          aliases:
+            - gsugambit-postfix

     memcached-mailcow:
       image: memcached:alpine
@@ -343,7 +346,9 @@ services:
         mailcow-network:
           aliases:
             - nginx
-
+        gsugambit-systems:
+          aliases:
+            - gsugambit-nginx
     acme-mailcow:
       depends_on:
         - nginx-mailcow
@@ -552,12 +557,15 @@ networks:
     driver: bridge
     driver_opts:
       com.docker.network.bridge.name: br-mailcow
-    enable_ipv6: true
+    enable_ipv6: false
     ipam:
       driver: default
       config:
         - subnet: ${IPV4_NETWORK:-172.22.1}.0/24
         - subnet: ${IPV6_NETWORK:-fd4d:6169:6c63:6f77::/64}
+  gsugambit-systems:
+    external:
+      name: gsugambit-systems
gsugambit commented 3 years ago

@andryyy in the entry point i see the below line. It is passing a "-f" parameter but the issue may be that "-f" is not an available parameter given the exception from the container.

 php -c /usr/local/etc/php -f /web/inc/init_db.inc.php
andryyy commented 3 years ago

No need to highlight me. :)

Check your timezone. What is it set to?

gsugambit commented 3 years ago

America/New York

gsugambit commented 3 years ago

Why I didn't use underscore you ask? because im sleepy :(

andryyy commented 3 years ago

Hehe, no problem. :) Glad that solves it. Hopefully. :)

gsugambit commented 3 years ago

Now I have a very interesting problem. I cannot route traffic to the nginx server through it's dockerized host name. Very interesting problem, I have to route traffic with the MACHINE_IP:9998. Pretty confusing. I can even curl localhost:9998 on the machine.

Here is what was added to haproxy which is pretty standard. This haproxy is running in a different docker compose but on same docker network. I can ping "gsugambit-nginx" from the haproxy container so i know connection is possible.

    acl mailcow hdr_beg(host) -i mail.
    use_backend mailcow if mailcow

backend mailcow
  option forwardfor
  http-request set-header X-Forwarded-Proto https if { ssl_fc }
  http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
  server mailcow gsugambit-nginx:9998 check

mailcow.conf

HTTP_PORT=9998
HTTP_BIND=0.0.0.0

HTTPS_PORT=9999
HTTPS_BIND=0.0.0.0

If I change the haproxy config to the below, then the UI works

server mailcow MY_SERVER_IP:9998 check
andryyy commented 3 years ago

Can you try HTTPS_BIND= and HTTP_BIND= (both just empty)?

gsugambit commented 3 years ago

Aha, I thought that was required! Now I'm having issue with with trying to add a domain and getting this issue: "Max. quota exceeds domain quota limit" but this seems like something i can investigate by learning how the mail client works. It's up now, appreciate that so much!

andryyy commented 3 years ago

Edit the domain and increase the general domain quota. :)

Yay, another cow user, one of us, one of us!

gsugambit commented 3 years ago

This is really confusing because I do have a name. Is there a regex I must meet? I restart the sogo container manually as well after intro'ing the new domain. image

andryyy commented 3 years ago

Your domain is missing a tld. Like .com. The UI should not accept it, I can look into that later.

gsugambit commented 3 years ago

Worked! I will spread this to all my friends. The setup was very easy. All the problems were user error lmfao

gsugambit commented 3 years ago

Are these all the dns records i need? image image

andryyy commented 3 years ago

There is a DNS button the domain table. You may want to use "v=spf1 mx a -all" as SPF, create a MX, DKIM key and perhaps a DMARC record. Check the community for support with that. We have a very active Telegram channel. :)