mriedmann / humhub-docker

Alpine-based PHP-FPM and NGINX HumHub docker-container
MIT License
95 stars 77 forks source link

502 Bad Gateway Error when connecting to PHP-FPM upstream in Nginx" #309

Closed PierreJiji closed 1 year ago

PierreJiji commented 1 year ago

Description:

I have deployed HumHub on OpenShift using the provided Docker image and environment variables on docker-compose.prod.yml. However, when I try to access the HumHub site through a web browser, I receive a "502 Bad Gateway" error. I have checked that the HumHub service is running and is accessible outside of the OpenShift cluster but not all the time.

Additionally, there are intermittent connection issues with the database, even though the database configuration appears to be correct.

Here are some of the error messages or logs that may be relevant:

[13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "NOTICE: PHP message: An Error occurred while handling another error:" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "PDOException: SQLSTATE[HY000] [2002] Connection refused in /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/Connection.php:722" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "Stack trace:" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#0 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/Connection.php(722): PDO->__construct()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#1 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/Connection.php(637): yii\db\Connection->createPdoInstance()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#2 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/Connection.php(1067): yii\db\Connection->open()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#3 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/Connection.php(1054): yii\db\Connection->getMasterPdo()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#4 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(413): yii\db\Connection->getSlavePdo()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#5 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(437): yii\db\mysql\QueryBuilder->supportsFractionalSeconds()" [13-Mar-2023 20:27:17] WARNING: [pool www] child 118 said into stderr: "#6 /var/www/localhost/htdocs/protected/vendor/yiisoft/yii2/db/mysql/QueryBuilde..."

2023/03/13 20:35:38 [error] 44#44: *69 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xxx.2.xx, server: _, request: "GET /sw.js?v=1678739737 HTTP/1.1", upstream: "fastcgi://172.30.81.xx:9000", host: "humhub-xxx.apps.xxx.openshift.xxx", referrer: "https://humhub-xxx.apps.xxx.openshift.xxx/user/auth/login"

Steps to reproduce:

Expected behavior:

The HumHub site should display the expected content without any errors.

Actual behavior:

The HumHub site displays a "502 Bad Gateway" error message, and there are intermittent connection issues with the database.

Thank you for your help in resolving this issue.

ArchBlood commented 1 year ago

Seems related to https://github.com/docker-library/php/issues/207

mriedmann commented 1 year ago

Hi!

Have you checked the db connection manually? (you can use curl -v <db-hostname> and see if it connects) Have you created a service for the db? (if not, have you used the exact pod-ip or pod-name to connect to the db?) Is it named "db"? (if you name the service "db" it should behave like the compose-file)

PierreJiji commented 1 year ago

Yes, I already have my database with all the tables, but sometimes the connection is refused and sometimes it is correct

mriedmann commented 1 year ago

That sounds like your db crashes or you readiness probe is incorrect. Please check if your DB has enough memory and cpu. You can also check the restart-counter and previous log (oc logs -p <podname>)

PierreJiji commented 1 year ago

I managed to install the application on Kubernetes EKS and everything was working fine, but I didn't get the same behavior on OpenShift. There may be something missing in the network configuration, but we can consider this issue resolved !

Thank you so much for ur help !

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.