2022-12-09 01:44:52 +00:00
|
|
|
# Setup Postgres database for PowerDNS-Admin
|
2022-12-08 15:52:02 +00:00
|
|
|
|
2022-12-09 01:44:52 +00:00
|
|
|
We assume you already have a postgres database software installed for your platform.
|
2022-12-08 15:52:02 +00:00
|
|
|
|
|
|
|
### Create database
|
2022-12-09 11:11:12 +00:00
|
|
|
The below will create a database called powerdnsadmindb and a user of powerdnsadmin.
|
|
|
|
|
2022-12-08 15:52:02 +00:00
|
|
|
```
|
|
|
|
$ sudo su - postgres
|
|
|
|
$ createuser powerdnsadmin
|
|
|
|
$ createdb powerdnsadmindb
|
|
|
|
$ psql
|
|
|
|
postgres=# alter user powerdnsadmin with encrypted password 'powerdnsadmin';
|
|
|
|
postgres=# grant all privileges on database powerdnsadmindb to powerdnsadmin;
|
|
|
|
```
|
|
|
|
|
|
|
|
Note:
|
|
|
|
- Please change the information above (db, user, password) to fit your setup.
|
2022-12-09 01:44:52 +00:00
|
|
|
|
|
|
|
### Setup Remote access to database:
|
2022-12-09 02:37:29 +00:00
|
|
|
If your database is on a different server postgres does not allow remote connections by default.
|
2022-12-09 01:44:52 +00:00
|
|
|
|
2022-12-09 11:11:12 +00:00
|
|
|
To change this follow the below directions:
|
2022-12-09 02:37:29 +00:00
|
|
|
```
|
|
|
|
[root@host ~]$ sudo su - postgres
|
|
|
|
# Edit /var/lib/pgsql/data/postgresql.conf
|
|
|
|
# Change the following line:
|
|
|
|
listen_addresses = 'localhost'
|
|
|
|
# to:
|
|
|
|
listen_addresses = '*'
|
|
|
|
# Edit /var/lib/pgsql/data/pg_hba.conf
|
|
|
|
# Add the following lines to the end of the
|
|
|
|
host all all 0.0.0.0/0 md5
|
|
|
|
host all all ::/0 md5
|
|
|
|
|
|
|
|
[postgres@host ~]$ exit
|
2022-12-09 11:11:12 +00:00
|
|
|
[root@host ~]$ sudo systemctl restart postgresql
|
2022-12-09 02:37:29 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
On debian based systems these files are located in:
|
|
|
|
```
|
|
|
|
/etc/postgresql/<version>/main/
|
|
|
|
```
|
2022-12-08 15:52:02 +00:00
|
|
|
|
2022-12-09 01:44:52 +00:00
|
|
|
## Docker
|
2022-12-09 11:11:12 +00:00
|
|
|
TODO: Setup a local Docker postgres database ready to go (should probably move to the top).
|
2022-12-08 15:52:02 +00:00
|
|
|
```
|
|
|
|
docker run --name pdnsadmin-test -e BIND_ADDRESS=0.0.0.0
|
|
|
|
-e SECRET_KEY='a-very-secret-key'
|
|
|
|
-e PORT='9191'
|
|
|
|
-e SQLA_DB_USER='powerdns_admin_user'
|
|
|
|
-e SQLA_DB_PASSWORD='exceptionallysecure'
|
|
|
|
-e SQLA_DB_HOST='192.168.0.100'
|
|
|
|
-e SQLA_DB_NAME='powerdns_admin_test'
|
|
|
|
-v /data/node_modules:/var/www/powerdns-admin/node_modules -d -p 9191:9191 ixpict/powerdns-admin-pgsql:latest
|
|
|
|
```
|