1

I have docker installation of GeoNode with all defaults: my_geonode, my_geonode_data etc. Now I'm truing to change default password for user my_geonode in PostgreSQL and I did. Also, I have change in .env file to new password

GEONODE_DATABASE=my_geonode
GEONODE_DATABASE_PASSWORD="my new password"

I'm not sure if this is an issue but after changing password geonode is not able to start:

psql: FATAL: password authentication failed for user "my_geonode"
my_geonode is unavailable - sleeping

I'm not sure if this is an issue or not but I do not know where else this new password should also be placed.

2 Answers 2

1

Looking at the docker-compose.yml file, postgis image is pulled instead of built (image: geonode/postgis:11). This means you won't be able to use a password different than the default one. In order to do that you'll need to build your own postgis image, and edit the postgres password or create a dedicated user.

But if you look at the network configuration, you'll se that the 'db' container isn't listening for external connections. The geonode container will connect to the db container using the local docker network bridge only. You won't be able to connect to your postgres instance from another host.

So in contrary of your geonode and geoserver admin passwords, keeping the default shouldn't induce security issues, as long as your docker host is secured !

1
  • Now all make a sense! Thank a lot. But in case of Geoserver password this can be changed in .env file and it works. Also I recommend to change it because geoserver is accessible from the internet and leaving default one can be security issue. Mar 3, 2021 at 7:32
0

Solution:

change password for geonode and geonode_data. Password can be changed thru pgadmin or with commands:

docker exec -i db4geonode psql -d geonode -U postgres -c "alter user geonode with password '654321';"
docker exec -i db4geonode psql -d geonode_data -U postgres -c "alter user geonode_data with password '654321';"

then the password should be changed in three files:

  1. tasks.py
  2. db.env
  3. django.env (or depending on instalactions just in .env file)

in tasks.py must be changed:

def _update_db_connstring():
    user = os.getenv('GEONODE_DATABASE', 'geonode')
    pwd = os.getenv('GEONODE_DATABASE_PASSWORD', '654321')
    dbname = os.getenv('GEONODE_DATABASE', 'geonode')
    connstr = 'postgres://{0}:{1}@db:5432/{2}'.format(
        user,
        pwd,
        dbname
    )
    return connstr

def _update_geodb_connstring():
    geouser = os.getenv('GEONODE_GEODATABASE', 'geonode_data')
    geopwd = os.getenv('GEONODE_GEODATABASE_PASSWORD', '654321')
    geodbname = os.getenv('GEONODE_GEODATABASE', 'geonode_data')
    geoconnstr = 'postgis://{0}:{1}@db:5432/{2}'.format(
        geouser,
        geopwd,
        geodbname
    )
    return geoconnstr

"db_url": os.environ.get('DATABASE_URL', 'postgres://geonode:654321@db:5432/geonode'),
"geodb_url": os.environ.get('GEODATABASE_URL', 'postgis://geonode_data:654321@db:5432/geonode_data'),
  1. in db.env
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_PASSWORD=654321
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_PASSWORD=654321
  1. in django.env
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_PASSWORD=654321
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_PASSWORD=654321

DATABASE_URL=postgresql://geonode:654321@db:5432/geonode
GEODATABASE_URL=postgis://geonode_data:654321@db:5432/geonode_data

then just run docker-compose up -d --build django

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.