Skip to content

Commit 8051f46

Browse files
authored
direct IP access (#238)
1 parent 4e2595b commit 8051f46

File tree

4 files changed

+241
-218
lines changed

4 files changed

+241
-218
lines changed

apps/docs/content/features/access.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ When using Let's Encrypt certificates (recommended):
173173

174174
For applications requiring direct port access or non-HTTP protocols, Zerops provides flexible port configuration options.
175175

176+
:::important
177+
Currently, direct public port access is only available for runtime services and PostgreSQL databases.
178+
:::
179+
176180
<p align="center">
177181
<Image
178182
src="/img/gui/ipv6-public-port.webp"
@@ -183,8 +187,11 @@ For applications requiring direct port access or non-HTTP protocols, Zerops prov
183187

184188
### Port Configuration
185189

186-
1. Navigate to service detail page in Zerops GUI, select **Public access & internal ports** and click **Setup first access through IPv6** or activate **Unique IPv4 add-on**
190+
1. Navigate to service detail page in Zerops GUI
191+
- For runtime services select **Subdomain & domain & IP access**
192+
- For PostgreSQL select **Direct access through IP address**
187193
2. Configure your port settings:
194+
- Either **Setup first access through IPv6** or activate **Unique IPv4 add-on** (if needed)
188195
- Choose any port from 10-65435 (except 80 and 443)
189196
- Select destination service and internal port
190197
- Each public port can be mapped to any internal service port
@@ -209,5 +216,4 @@ Optionally secure your ports with firewall rules:
209216
alt="Enable Firewall"
210217
style={{ width: '90%', height: 'auto' }}
211218
/>
212-
</p>
213-
219+
</p>

apps/docs/content/postgresql/how-to/connect.mdx

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,67 @@ title: Connect to PostgreSQL in Zerops
33
description: Learn how to connect to your PostgreSQL database in Zerops from various environments.
44
---
55

6-
This guide covers how to connect to your PostgreSQL database in Zerops, both from services within the same project and from your local workstation.
6+
This guide covers how to connect to your PostgreSQL database in Zerops, both from services within the same project and from outside the Zerops environment.
77

88
## Connection Options Overview
99

10-
Zerops provides two primary ways to connect to PostgreSQL:
10+
Zerops provides several ways to connect to PostgreSQL:
1111

1212
1. **Internal connections** - Between services in the same Zerops project (via private network)
13-
2. **Remote connections** - From your local machine (via Zerops VPN)
14-
15-
:::caution
16-
For security reasons, Zerops doesn't allow exposing PostgreSQL services directly to the internet.
17-
:::
13+
2. **Remote connections**:
14+
- **VPN access** - From your local machine via Zerops VPN
15+
- **Direct IP access** - Enables external applications to connect using TLS encryption by opening public ports on IPv6 (available by default) or IPv4 (requires add-on activation if not already enabled)
1816

1917
## Connection Details
2018

21-
You'll find PostgreSQL connection details in two places in the Zerops GUI:
19+
You'll find internal PostgreSQL connection details in two places in the Zerops GUI:
2220

2321
1. Under the **Access details** button in the project dashboard
2422
2. In the service detail page under the **Peek access details** button
2523

2624
### Connection Parameters
2725

28-
| Parameter | Description |
29-
| --------------------- | --------------------------------------------------------------------- |
30-
| **Hostname** | Identical to the service hostname |
31-
| **Port** | **5432** (fixed for all PostgreSQL services) |
32-
| **User** | Identical to the service hostname |
33-
| **Password** | Randomly generated during service creation |
34-
| **Connection string** | `postgresql://${user}:${password}@{hostname}:5432` |
26+
<table className="w-full my-1.5">
27+
<thead>
28+
<tr>
29+
<th className="w-fit">Parameter</th>
30+
<th className="w-fit">Internal Connection</th>
31+
<th className="w-fit">Direct IP Access (TLS)</th>
32+
</tr>
33+
</thead>
34+
<tbody>
35+
<tr>
36+
<td className="w-fit font-semibold whitespace-nowrap">Hostname/IP</td>
37+
<td className="w-fit">Service hostname</td>
38+
<td className="w-full">Public IP address</td>
39+
</tr>
40+
<tr>
41+
<td className="w-fit font-semibold whitespace-nowrap">Port</td>
42+
<td className="w-fit">5432</td>
43+
<td className="w-full">6432</td>
44+
</tr>
45+
<tr>
46+
<td className="w-fit font-semibold whitespace-nowrap">User</td>
47+
<td className="w-fit">Identical to the service hostname</td>
48+
<td className="w-full">Same as internal</td>
49+
</tr>
50+
<tr>
51+
<td className="w-fit font-semibold whitespace-nowrap">Password</td>
52+
<td className="w-fit">Randomly generated during service creation</td>
53+
<td className="w-full">Same as internal</td>
54+
</tr>
55+
<tr>
56+
<td className="w-fit font-semibold whitespace-nowrap">Port env variable</td>
57+
<td className="w-fit">`port`</td>
58+
<td className="w-full">`portTls`</td>
59+
</tr>
60+
<tr>
61+
<td className="w-fit font-semibold whitespace-nowrap">Connection string env variable</td>
62+
<td className="w-fit">`connectionString`</td>
63+
<td className="w-full">`connectionTlsString`</td>
64+
</tr>
65+
</tbody>
66+
</table>
3567

3668
:::warning
3769
Zerops creates a system user named `zps` with full privileges for maintenance purposes. Do not delete, change the password, or remove privileges from this user, as it will disrupt Zerops' ability to maintain the database cluster.
@@ -72,6 +104,10 @@ For more details on how to use environment variables, and instructions for addin
72104

73105
## Connect Remotely
74106

107+
Zerops offers two methods for connecting to your PostgreSQL database from outside the Zerops environment:
108+
109+
### Method 1: Connect via Zerops VPN
110+
75111
You can securely connect to PostgreSQL from your local workstation via Zerops VPN:
76112

77113
1. [Install & set up zCLI](/references/cli)
@@ -84,4 +120,23 @@ You can securely connect to PostgreSQL from your local workstation via Zerops VP
84120
* If your connection over VPN doesn't work, try adding `.zerops` suffix to the service hostname (e.g., `database1.zerops`). For additional help, check the [VPN troubleshooting page](/references/vpn/troubleshooting).
85121
:::
86122

123+
### Method 2: Connect via Direct IP Access
124+
125+
Direct IP Access uses [pgBouncer](https://www.pgbouncer.org/) for connection pooling and TLS termination.
126+
127+
Internally, port `5432` is available without SSL. Externally, connections are secured with TLS through pgBouncer (port `6432`) before being routed to your PostgreSQL service.
128+
129+
#### Enable external access
130+
131+
1. Navigate to your PostgreSQL service in the Zerops GUI and choose the **Public Access through IP Addresses** section
132+
2. Choose either IPv6 (available by default) or IPv4 (requires the [unique IPv4](/features/access#dedicated-ipv4-address-330-days) add-on)
133+
3. Open one or more ports and point them to your PostgreSQL service (the system will direct them through pgBouncer)
134+
- Choose any port from 10-65435 (except 80 and 443)
135+
- Select destination service and internal port
136+
- Each public port can be mapped to any internal service port
137+
- Multiple public ports can point to the same internal port if needed
138+
- Port configurations can be set independently for IPv4 and IPv6
139+
4. Optionally enable firewall protection for additional security
140+
5. Click the **Publish X IP access change(s)** button to apply your settings
141+
87142
For database management tools and how to manage users and databases, see [Manage PostgreSQL Users and Databases](/postgresql/how-to/manage).

0 commit comments

Comments
 (0)