Expose database server (PostgreSQL)
This tutorial will show you how you can expose your database (PostgreSQL as an example) with LocalXpose, along with enabling SSL on your PostgreSQL instance.
Last updated
Was this helpful?
This tutorial will show you how you can expose your database (PostgreSQL as an example) with LocalXpose, along with enabling SSL on your PostgreSQL instance.
Last updated
Was this helpful?
If you are running Linux, you can install it using your package manager from your Distribution repository. Check the official installation for more details if you are using Windows or macOS.
Once installed,
We can reserve an endpoint for this specific use case.
If you want to use your own domain name, you will need to add a CNAME DNS
record for your domain to the endpoint reserved for your PostgreSQL Server, take this screenshot for reference.
Here we have created a sub-domain psql.xtestgo.xyz as an alias to ap-2.loclx.io.
PostgreSQL runs default in port 5432, lets run LocalXpose to expose that port.
Next, you can connect to your PostgreSQL database from anywhere you want.
Once done, you will find your certificates, in the path mentioned.
You might need to verify permissions of those certificate files.
File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root.
Next, go ahead and update /etc/postgresql/12/main/postgresql.conf
with few of the newer parameters.
Some operating system may have a different postgresql.conf
path, You can find it with the following command.
Find the SSL section in the postgresql.conf
file and change it like so.
Save the config file once done.
pg_hba.conf
is in the same path as postgresql.conf
file, you will need to allow external connections by adding the following lines.
Next save the file and restart PostgreSQL Server.
Similar to one mentioned above you can now connect to your postgresql database, and your conection should be encrypted with SSL.
If you don't see a message regarding SSL information, you might want to check PostgreSQL log file located on/var/log/postgresql/postgresql-12-main.log
.
You can see the current connections by querying pg_catalog.pg_stat_ssl.
If you want LocalXpose to start during boot and start exposing this port, You can create a daemon by writing a systemd unit file similar to .
You might want to configure PostgreSQL to use SSL. Follow the following guide to setup ssl with postgresql, Here we use free certificates, but if you have your own, you may use it.
has built-in , you can use it to get SSL certs in few seconds.
You can now proceed to use your Postgresql database. Similarly you can connect to your database using the same endpoint/domain with other tools like or