Access PostgreSQL Data Source through the NineData Gateway
NineData supports accessing PostgreSQL data sources through a gateway, allowing you to connect to PostgreSQL without providing an external address, even if it's in a private or dedicated network environment.
Before you begin
- The host where the gateway is deployed must be in the private network of the PostgreSQL data source and must be able to access the PostgreSQL data source.
- The host where the gateway is deployed must have internet access. If the host is in a local network and cannot access the internet, deploy a proxy gateway. For more information, see Using a Proxy Gateway.
Step 1: Deploy the Gateway
Use this step when the gateway host can access the public internet. If the host can access only a local area network, use Proxy Gateway to deploy the gateway.
Sign in to the NineData console on the host where you want to deploy the gateway.
In the left navigation pane, select Datasource > Gateway.
Select Create Gateway.
Configure the following parameters.
Parameter Description Name Enter a gateway name that is easy to search and manage. Manual names are supported. Environment Select the operating system of the gateway host. NineData displays the corresponding gateway installation method. The following operating systems are supported: - Windows(x86_64)
- Linux(x86_64)
- macOS
Access Region Select the region closest to the gateway host to reduce network latency. Advanced No configuration required. Follow the displayed installation method to install and configure the gateway on the deployment host. When the gateway connects successfully, the connection diagram changes from Waiting for the local gateway to launch... to The local gateway is connected successfully.
Select Create Datasource, choose the data source to add in the selection window, and proceed to Step 2.
Step 2: Access the PostgreSQL Data Source
On the Create Datasource page, configure the parameters in the table.
Parameter Description Name Enter the data source name. Use a meaningful name to identify and manage the data source later. Connection Select Gateway. Gateway Select the gateway ID deployed in Step 1. Host Enter the access address and port of the PostgreSQL data source. - If PostgreSQL is installed on the local machine: Enter
localhostor127.0.0.1for the address and the actual port of PostgreSQL for the port. - If PostgreSQL is installed on another host in the private network: Enter the private IP address of that host for the address and the actual port of PostgreSQL for the port.
DB Account Enter the login username for PostgreSQL. DB Password Enter the login password for PostgreSQL. Access Region Select the region closest to your PostgreSQL host to effectively reduce network latency. Environment Select the environment that matches the business purpose of the data source. The default provides the PROD and DEV environments, and also supports you to create a custom environment.
Note: In organization mode, the database environment can also be applied to permission policy management. For example, the default Prod Admin role only supports access to data sources in the PROD environment and cannot access data sources in other environments. For more information, see Managing Roles.Encryption Configure SSL encryption for the data source (default: off). If the data source requires SSL encryption, enable this switch, or the connection fails.
Use the switch to enable or disable encrypted transmission. Click the left side of Encryption to expand detailed configuration.- SSL Options: Supports four options:
- Prefer: Detects the server SSL status. If SSL is enabled on the server, NineData connects with SSL. If SSL is not enabled, NineData connects without SSL.
- Require: Always connects with SSL. If the server does not support this method or cannot establish an SSL connection for other reasons, the connection fails.
- Verify-CA: Upload a CA certificate to verify whether the server certificate is signed by a trusted authority and help prevent man-in-the-middle attacks. Optionally upload a client user certificate and key to verify your identity and encrypt communication with the server.
- Verify-full: Based on Verify-CA, also verifies whether the server certificate subject, such as hostname or IP address, matches the connected server.
- CA Cert: Required when SSL Options is Verify-CA or Verify-Full. Specifies the CA certificate used to verify the server certificate.
- Client Certificate (optional): If the server requests a client certificate, upload the client certificate to verify your identity. Client Certificate contains the user certificate (.pem) and key (.pk8).
- Key Password: If the uploaded client key file is password-protected, enter the password here. Leave it blank if no password is set for the client key.
- If PostgreSQL is installed on the local machine: Enter
After configuring the parameters, click Connection Test next to Create Datasource to verify that NineData can reach the data source. When Connection Successfully appears, click Create Datasource to add the data source. If the test fails, review the connection settings and run the test again.
Appendix: Using a Proxy Gateway
If the gateway host cannot access the public internet, use a proxy gateway. Prepare two hosts in the same LAN that can reach each other:
- Host A: A host that can access the public internet.
- Host B: The host where you deploy the gateway.
Create a gateway on Host A to act as a proxy so Host B can connect to the NineData server through it.
Procedure
Sign in to the NineData console on Host A.
In the left navigation bar, select Datasource > Gateway.
Select Create Gateway.
Configure the following parameters.
Parameter Description Name Enter a gateway name that is easy to search and manage. Specify the gateway name manually. Environment Select the operating system of the gateway host. NineData displays the corresponding gateway installation method. The following operating systems are supported: - Windows (x86_64)
- Linux (x86_64)
- macOS
Access Region Select the region closest to the gateway host to reduce network latency. Advanced No configuration is required. Follow the displayed installation method to install and configure the gateway on Host A. When the gateway connects successfully, the connection diagram changes from Waiting for the local gateway to launch... to The local gateway is connected successfully.
Select Completed and back to List, and then select Create Gateway again.
In Environment, select the operating system of Host B.
Select Advanced, select Use Proxy, and open the dropdown under Proxy. Select the gateway created on Host A.
tipNineData opens a proxy port on Host A for Host B. When the page shows
<gateway_name> has enabled proxy function, port <port>, the proxy gateway is ready.Follow the displayed installation steps to install the gateway on Host B.
Wait until the connection diagram changes from Waiting for the local gateway to launch... to The local gateway is connected successfully.
Select Create Datasource to proceed to Step 2.