Configure external access to bundled PostgreSql

Hello all,

I want to configure external access to bundled PostgreSql of Gitlab. I’ve been looked all over the internet and tried some stuff, but changing pg_hba.conf brings me only errors.

I’m using Gitlab self-managed installation with default values and I want to configure Apache Superset in order to create some dashboards. The problem is I don’t know how to configure bundled Postgre so my Superset can access to it, it is installed on the same machine.

Can someone guide me how to create read_only user, what Roles should I give it and most important how to configure pg_hba.conf, because when I tried to change values it throws error 504 on Gitlab’s web interface. I don’t want to use external database, no need for that, just need access from Superset so it can read some tables but I’m bit of scared that I’ll lost my data if I reconfigure something that I should not. On internet I can only find info about external databases

Can anyone help me out?


I took a quick look into this, and I see a lot of configuration in /etc/gitlab/gitlab.rb, for example:

# postgresql['enable'] = true
# postgresql['listen_address'] = nil
# postgresql['port'] = 5432

these values could be configured, but since the bundled postgresql works on a socket, I’ve no idea what will happen with your Gitlab when you configure these instead. It may also require you following the Gitlab docs for configuring the external Postgres at this point, so that Gitlab connects to the bundled Postgresql via IP instead of socket. That’s even before we start looking at configuring pg_hba.conf or anything else to allow access. I already see in pg_hba.conf that Gitlab is configured to use local socket and not IP so means that is another change that needs to be made. The PostgreSQL documentation will explain possible configuration options for that - which can be found by searching with Google.

To be honest, you would probably be far better just installing and configuring an external PostgreSQL and using that instead of attempting to change the way the bundled PostgreSQL works, which from what I see will be more complicated than just configuring an external PostgreSQL.

As for creating a read-only user, that can be found easy enough with Google - the PostgreSQL documentation will have that, and examples are easy enough to find using Google or whatever. Generally though, you just create a user with a password, and then you grant the specific access on the database to that user.

I cannot help more than that, it’s something you’ll just have to try and test. As already said, would be far easier for you to just install and configure an external PostgreSQL and use that instead of the bundled one. Good luck.

Hi iwalker,

Thanks for the reply. Yes, I’ve tried changing gitlab.rb and my gitlab interface was broken, error 504 I think. This is why I needed more info about bundled db. I thought about using external DB, but not sure how to migrate bundled DB into external and what will happen. Maybe I’ll give a try, but still I think that this can be done via bundled DB, just don’t know how. The biggest problem is if I change some parameters in gitlab.rb will that broke my current DB and will I be able to restore it

You can use this: Moving GitLab databases to a different PostgreSQL instance | GitLab

It explains how to dump the database and then import on a new Postgres installation. PostgreSQL 14 is the latest supported with 16.9.x anyway, so you’ll be wanting to install Postgres 14. If earlier version of Gitlab then you need to check what version is supported with it: PostgreSQL versions shipped with the Linux package | GitLab

For the embedded Postgres, make yourself a test server and play around with configuring that if you want to try and get the bundled Postgres to work. If it breaks, then you don’t lose your system. Better than doing it on your production/live server.

Yeah, obviously not smart to do anything on production. I will see these days to create a test server. Thanks iwalker

1 Like