Static IP for Cloud Run and Cloud Functions
Route allowlisted calls from Cloud Run and Cloud Functions through a fixed IPv4 without managing VPC subnets or paying for Cloud NAT.
First payment refunded within 7 days if it doesn’t work for you
- Partner API
- External DB
On this page15
Cloud Run services, Cloud Run Jobs, and Cloud Functions (2nd gen) exit from shared rotating Google Cloud ranges by default. Google’s native static IP stack requires a VPC, Serverless VPC Access (or Direct VPC Egress), Cloud Router, and Cloud NAT, adding 24/7 hourly fees and per-GB charges. With Prontaro, regular service traffic stays direct while selected calls route through your /32 — configured with a single environment variable.
Prontaro and Cloud NAT with Serverless VPC Access
| Dimension | Prontaro | Cloud NAT + Serverless VPC Access |
|---|---|---|
| Setup | 5 minutes: one environment variable or secret | VPC, subnets, connector, Cloud Router, Cloud NAT, routing |
| Traffic scope | Only the external APIs you choose | All egress from the service (or custom subnet routing) |
| Cost | From $12/month (100 GB traffic included) | 24/7 hourly connector VMs + Cloud NAT hourly + per-GB fees |
| IP reuse | Same IP works in CI, local dev, and other clouds | Locked to one VPC in a single GCP region |
Which method to choose
| Cloud Run / Cloud Functions task | Prontaro method | Best for |
|---|---|---|
| Partner HTTPS APIs and payment gateways | HTTPS proxy (PRONTARO_PROXY_URL) |
End-to-end TLS and mTLS over HTTP CONNECT (:443) |
| Single REST API without proxy libraries | Relay URL (PRONTARO_RELAY_URL) |
Swap only the base URL in built-in fetch |
| Allowlisted external databases | socks5h:// or prontaro forward |
Forwards TCP connections to PostgreSQL and MongoDB |
Prerequisites
- A Prontaro account on Dedicated (from $12/month) or Pro (plans and pricing).
- A dedicated IPv4 in the Prontaro location closest to your GCP region (available locations are shown in the dashboard).
- A Google Cloud project with
gcloudCLI installed (or Google Cloud Console access).
Step 1. Create proxy credentials and allowlist your IP
Add your dedicated IPv4 (/32) to the partner allowlist, then create dedicated proxy credentials for Cloud Run in the dashboard. Leave the To destination list open until you verify the outbound IP.
- Open IP addresses in my.prontaro.com and click Create proxy credentials.
- Name them
cloud-run-prodand copy theHTTPSURL (port:443).
Step 2. Pass PRONTARO_PROXY_URL to Cloud Run or Cloud Functions
Production: Google Secret Manager (recommended)
Store the URL in Secret Manager, grant your Cloud Run service account roles/secretmanager.secretAccessor, and expose it as PRONTARO_PROXY_URL:
printf '%s' "https://u_gcp:s3cr3t@<entry>.prontaro.io:443" \
| gcloud secrets create prontaro-proxy-url --data-file=-
# For Cloud Run:
gcloud run services update my-service \
--region europe-west3 \
--set-secrets="PRONTARO_PROXY_URL=prontaro-proxy-url:latest"
# For Cloud Functions (2nd gen):
gcloud functions deploy my-function \
--gen2 \
--region europe-west3 \
--set-secrets="PRONTARO_PROXY_URL=prontaro-proxy-url:latest"Quick start with --set-env-vars
For fast testing, set the environment variable directly on a new revision:
gcloud run services update my-service \
--region europe-west3 \
--set-env-vars="PRONTARO_PROXY_URL=https://u_gcp:s3cr3t@<entry>.prontaro.io:443"Or configure it in the Google Cloud Console:
- PRONTARO_PROXY_URL
- https://u_gcp:s3cr3t@<entry>.prontaro.io:443
Step 3. Configure the HTTP client in code
Node.js 20+ (undici)
Install undici (npm install undici) and instantiate ProxyAgent once at module scope so concurrent Cloud Run requests reuse connections:
// src/partner.mjs
import { fetch, ProxyAgent } from 'undici';
const proxyUrl = process.env.PRONTARO_PROXY_URL;
if (!proxyUrl) {
throw new Error('PRONTARO_PROXY_URL is not configured');
}
const agent = new ProxyAgent({
uri: proxyUrl,
connections: 20,
});
export async function callPartner(path = '/v1/status') {
const response = await fetch(`https://api.example.com${path}`, {
dispatcher: agent,
headers: {
Authorization: `Bearer ${process.env.PARTNER_API_TOKEN}`,
},
signal: AbortSignal.timeout(15_000),
});
if (!response.ok) {
throw new Error(`Partner API returned ${response.status}`);
}
return response.json();
}Python 3.11+ (httpx)
Install httpx (pip install httpx) and keep a single module-level client:
# partner.py
import os
import httpx
client = httpx.Client(
proxy=os.environ["PRONTARO_PROXY_URL"],
timeout=httpx.Timeout(15.0, connect=5.0),
limits=httpx.Limits(max_connections=20, max_keepalive_connections=10),
)
def call_partner(path: str = "/v1/status") -> dict:
response = client.get(
f"https://api.example.com{path}",
headers={"Authorization": f"Bearer {os.environ['PARTNER_API_TOKEN']}"},
)
response.raise_for_status()
return response.json()The exact same code works in Cloud Run Jobs and Cloud Functions (2nd gen).
Step 4. Verify the outbound IP
Before restricting allowed destinations, point a temporary check endpoint at https://api.ipify.org?format=json, deploy the revision, and call it:
curl -fsS https://my-service-xxxx-ey.a.run.app/egress-check
{"ip":"203.0.113.10"}Confirm the returned address matches your dedicated IPv4 in my.prontaro.com, then remove the check route.
Step 5. Lock down allowed destinations
Once verified, restrict cloud-run-prod to the exact partner hosts and ports:
- Open IP addresses → Proxy credentials in my.prontaro.com, select
cloud-run-prod, switch to Access, and addapi.example.com:443under To. - Save.
Google Cloud Run notes and limits
- Pair close regions: pick the Prontaro location in the dashboard closest to your Cloud Run region to minimize latency.
- Autoscaling and connection pools: each instance opens its own pool, while connection limits apply per IP. Keep
connections/max_connectionsat10–20and set--max-instances. - Cloud Run Jobs: work identically; for batch jobs reaching allowlisted databases, use
socks5h://orprontaro forwardwithPRONTARO_KEYexposed from Secret Manager. - BGP failover: on a server outage or reboot, Prontaro moves your
/32to a standby Prontaro server without changing the allowlisted IP. Active TCP sessions close; retries immediately resume from the same IP.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
PERMISSION_DENIED on deploy with --set-secrets |
Cloud Run service account cannot read the Secret Manager secret. | Grant roles/secretmanager.secretAccessor on prontaro-proxy-url. |
407 Proxy Authentication Required |
Trailing newline in the Secret Manager payload, or new credentials are still propagating. | Write the secret without a newline (printf '%s') and copy the exact URL under IP addresses. |
403 Forbidden from proxy |
Target host or port is missing from the To list. | Add <host>:443 under To in the credentials’ Access tab. |
| GCP metadata errors or unexpected Prontaro traffic | Global HTTPS_PROXY intercepted googleapis.com or 169.254.169.254. |
Remove global HTTPS_PROXY and pass PRONTARO_PROXY_URL only to external API clients. |
Next steps
- Static IP for AWS Lambda — the same pattern for AWS Lambda without VPC or NAT Gateway.
- PostgreSQL and AWS RDS with a static IP — TLS and driver setup for allowlisted databases.
- Language guides — proxy examples for Node.js, Python, Go, PHP, and Java.
- HTTP & SOCKS5 proxy — proxy credentials, protocols, and allowed destination rules.
Related guides
- HTTP & SOCKS5 proxyRoute outbound HTTP, HTTPS, and TCP connections through your static IPv4 with one proxy credential set, end-to-end TLS, and From/To rules.
- Relay URLsCall IP-allowlisted HTTPS APIs from edge runtimes and no-code tools without proxy configuration by replacing the base URL with a Prontaro Relay URL.
- Local port forwarding (prontaro forward)Connect database drivers, SFTP clients, and CLI tools to remote servers from your static IPv4 over a local TCP port — no proxy support needed.
Something wrong on this page? Contact us