konga: Cannot connect to Postgres with SSL

Hi,

For some reason Konga won’t connect to RDS Postgres in SSL.

Here’s the compose:

    image: pantsel/konga:latest
    environment:
      DB_ADAPTER: postgres
      DB_DATABASE: xxxx
      DB_HOST: xxxxx
      DB_PASSWORD: xxxxx
      NODE_ENV: development
      DB_SSL: 'true'
    stdin_open: true
    tty: true
    command:
    - printenv
    - '&&'
    - /bin/bash
    - ./start.sh

And the error log:

23/11/2017 15:02:53Failed to connect to DB named `xxxx` { error: no pg_hba.conf entry for host "x.x.x.x", user "xxx", database "xxx", SSL off
23/11/2017 15:02:53    at Connection.parseE (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
23/11/2017 15:02:53    at Connection.parseMessage (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
23/11/2017 15:02:53    at Socket.<anonymous> (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
23/11/2017 15:02:53    at emitOne (events.js:96:13)
23/11/2017 15:02:53    at Socket.emit (events.js:188:7)
23/11/2017 15:02:53    at readableAddChunk (_stream_readable.js:176:18)
23/11/2017 15:02:53    at TCP.onread (net.js:547:20)
23/11/2017 15:02:53  name: 'error',
23/11/2017 15:02:53  length: 152,
23/11/2017 15:02:53  severity: 'FATAL',
23/11/2017 15:02:53  code: '28000',
23/11/2017 15:02:53  detail: undefined,
23/11/2017 15:02:53  hint: undefined,
23/11/2017 15:02:53  position: undefined,
23/11/2017 15:02:53  internalPosition: undefined,
23/11/2017 15:02:53  internalQuery: undefined,
23/11/2017 15:02:53  where: undefined,
23/11/2017 15:02:53  schema: undefined,
23/11/2017 15:02:53  table: undefined,
23/11/2017 15:02:53  column: undefined,
23/11/2017 15:02:53  dataType: undefined,
23/11/2017 15:02:53  constraint: undefined,
23/11/2017 15:02:53  file: 'auth.c',
23/11/2017 15:02:53  line: '467',
23/11/2017 15:02:53  routine: 'ClientAuthentication' }

As you can see in the log it has SSL off, despite it being enabled in the environment variables.

It looks like this line is being ignored: https://github.com/pantsel/konga/blob/master/config/connections.js#L82

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@jessequinn

i am also receiving Failed to connect to DB { error: no pg_hba.conf entry for host "179.216.8.119", user "jessequinn_dev", database "kong", SSL off with DB_SSL: ‘true’ in docker-compose with the prepare statement.

  konga-prepare:
    image: pantsel/konga:next
    command: "-c prepare -a postgres -u postgresql://XXX/kong?sslmode=require"
    environment:
      DB_SSL: 'true'
    restart: on-failure
    depends_on:
      - kong

This is solved by adding “ssl=true” to the end of the connection string. For this example, it has ‘sslmode=require’ which isn’t picked up by the parser. The prepare function also seems to ignore the settings in the .env file to do with DB_SSL.

@flaccid , the image is building as we speak.

Just published the 0.9.1 release

The fix is actually adequate from https://github.com/pantsel/konga/commit/53446d5d1dbe5deec983817ffcdf31000670a4c1. However, there has been no release yet. @pantsel can you do another release and so the docker image gets the update?