zammad / zammad-docker-compose

Zammad Docker images for docker-compose
https://hub.docker.com/r/zammad/zammad-docker-compose/
GNU Affero General Public License v3.0
268 stars 208 forks source link

Password authentication failed for user "zammad" after upgrading to Zammad 6.x #355

Closed TuringTux closed 1 year ago

TuringTux commented 1 year ago

Description

After upgrading to Zammad 6.x using the Docker configuration from this repository, the instance won't start up anymore, because the init container fails to connect to postgres.

We have specified a custom POSTGRES_PASS in .env, which previously worked. I noticed that in the new release, the zammad-init container doesn't have the POSTGRESQL_USER and POSTGRESQL_PASS variables set. Do I have to provide the password to the init container differently?

Infos

Expected behavior

Actual behavior

Zammad does not start up, but the init container does instead fail with the message:

zammad-zammad-init-1           | PG::ConnectionBad: FATAL:  password authentication failed for user "zammad"
zammad-zammad-init-1           | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
zammad-zammad-init-1           | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `new'
zammad-zammad-init-1           | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/connection_handling.rb:283:in `connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/relation/delegation.rb:93:in `connection'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/relation/query_methods.rb:1396:in `preprocess_order_args'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/relation/query_methods.rb:383:in `reorder!'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/relation/query_methods.rb:378:in `reorder'
zammad-zammad-init-1           | /usr/local/bundle/gems/activerecord-6.1.7.3/lib/active_record/querying.rb:22:in `reorder'
zammad-zammad-init-1           | /opt/zammad/app/models/setting.rb:105:in `load'
zammad-zammad-init-1           | /opt/zammad/app/models/setting.rb:56:in `get'

Steps to reproduce

TuringTux commented 1 year ago

It seems like the lines

      - POSTGRESQL_USER=${POSTGRES_USER}
      - POSTGRESQL_PASS=${POSTGRES_PASS}

need to be added to the environment section of zammad-init, zammad-scheduler, zammad-railsserver, zammad-websocket. Update 2023-08-02: For the currently latest version of zammad, they also need to be added to zammad-nginx

MrGeneration commented 1 year ago

why not use the ENV file.

TuringTux commented 1 year ago

Sorry, I do not understand what you mean.

I am in fact using the .env file (as I always have been), which contains the variables POSTGRES_USER and POSTGRES_PASS just like in the example given in this repository.

However, it appears as those variables are not passed to the containers zammad-init, zammad-scheduler, zammad-railsserver and zammad-websocket anymore (where they are all needed), due to a missing declaration int the docker-compose.yml file.

AnXh3L0 commented 1 year ago

I am trying to deploy the Docker version in our server, and I'm having issues setting things up. Below you'll find logs for the part that fails.

https://logpaste.com/joZhv4yL

TuringTux commented 1 year ago

@AnXh3L0 Without having looked to much into your problem, these were the changes I needed to make to docker-compose.yml to get my instance up again:

diff --git a/docker-compose.yml b/docker-compose.yml
index b1640d0..8d207b5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -35,6 +35,8 @@ services:
       - zammad-postgresql
     environment:
       - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
+      - POSTGRESQL_USER=${POSTGRES_USER}
+      - POSTGRESQL_PASS=${POSTGRES_PASS}
       - REDIS_URL=${REDIS_URL}
     image: ${IMAGE_REPO}:${VERSION}
     restart: on-failure
@@ -78,6 +80,8 @@ services:
       - zammad-redis
     environment:
       - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
+      - POSTGRESQL_USER=${POSTGRES_USER}
+      - POSTGRESQL_PASS=${POSTGRES_PASS}
       - REDIS_URL=${REDIS_URL}
     image: ${IMAGE_REPO}:${VERSION}
     restart: ${RESTART}
@@ -99,6 +103,8 @@ services:
     environment:
       - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
       - REDIS_URL=${REDIS_URL}
+      - POSTGRESQL_USER=${POSTGRES_USER}
+      - POSTGRESQL_PASS=${POSTGRES_PASS}
     image: ${IMAGE_REPO}:${VERSION}
     restart: ${RESTART}
     volumes:
@@ -112,6 +118,8 @@ services:
       - zammad-redis
     environment:
       - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
+      - POSTGRESQL_USER=${POSTGRES_USER}
+      - POSTGRESQL_PASS=${POSTGRES_PASS}
       - REDIS_URL=${REDIS_URL}
     image: ${IMAGE_REPO}:${VERSION}
     restart: ${RESTART}
@@ -120,13 +128,16 @@ services:

 volumes:
   elasticsearch-data:
-    driver: local
+    external: true
+    name: zammad_elasticsearch-data
   postgresql-data:
-    driver: local
+    external: true
+    name: zammad_postgresql-data
   redis-data:
     driver: local
   zammad-backup:
-    driver: local
+    external: true
+    name: zammad_zammad-backup
   zammad-config-nginx:
     driver: local
   zammad-var:

I needed to fix two unrelated problems:

AnXh3L0 commented 1 year ago

@TuringTux Thanks, I managed to get the instance to boot and load. Now I am trying to reverse proxy it because I use Nginx, but I can't seem to access the instance via https (it only responds on domain:8080) and I get CSRF error (I did try the solution from the docs regarding that, but no luck till now).

fliebe92 commented 1 year ago

Hi there! Recently, there was a small change that could solve the reported behavior here: https://github.com/zammad/zammad/commit/6dc6b0fae5089a7a81b1a5f107f972b9ca279247

bykof commented 1 year ago

@AnXh3L0 CSRF sounds like you do not pass X-Forwarded-Proto headers to the nginx container,

mgruner commented 1 year ago

Should be fixed by #366

mgruner commented 1 year ago

Solved by 7f31a9a