# curl and environment variables

Source: https://prontaro.com/docs/languages/curl/

Verify your dedicated static IPv4 from the terminal with curl (via -x or shell proxy variables), and inspect proxy rejections using curl -v.

Because `curl` supports all three Prontaro proxy schemes (`https://`, `http://`, and `socks5h://`) out of the box, it is the quickest way to confirm credentials and outbound routing before wiring them into application code.

## Step 1. Get your proxy URL

1. Open **IP addresses** in your Prontaro dashboard ([my.prontaro.com/ips](https://my.prontaro.com/ips)) and select your dedicated IPv4.
2. Copy the `HTTPS` proxy string under **Proxy credentials** (or create dedicated credentials for this script).

IP addresses Proxy credentials [Open in dashboard](https://my.prontaro.com/ips)

Export the proxy string to `PRONTARO_PROXY_URL`:

```bash
export PRONTARO_PROXY_URL="https://user:pass@<entry>.prontaro.io:443"
```

## Step 2. Verify your outbound IP

Pass the proxy string with `-x` (short for `--proxy`) and request `https://api.ipify.org`:

```
 curl -fsS -x "$PRONTARO_PROXY_URL"
203.0.113.10
```

The output should match your dedicated IPv4. The `-fsS` flags hide the progress meter, keep error messages visible, and exit non-zero on HTTP `4xx`/`5xx` — ideal for shell scripts and CI jobs.

Once this check succeeds, you can restrict destinations in the dashboard (**IP addresses → Proxy credentials → Access**). Do not add destination restrictions before running this test, or `api.ipify.org` will return `403` because the host is not on your allowlist.

## Proxy schemes: `https://`, `http://`, and `socks5h://`

A single set of proxy credentials works across all three ports. Switching protocols in `curl` only requires changing the URL passed to `-x`:

| Scheme and port | Example | When to use |
| --- | --- | --- |
| `https://` (`:443`) | `https://user:pass@<entry>.prontaro.io:443` | Default choice: encrypts proxy credentials over TLS and opens an end-to-end `CONNECT` tunnel |
| `http://` (`:8080`) | `http://user:pass@<entry>.prontaro.io:8080` | Older `curl` builds without HTTPS-proxy support (target HTTPS stays end-to-end encrypted) |
| `socks5h://` (`:1080`) | `socks5h://user:pass@<entry>.prontaro.io:1080` | Testing SOCKS5 routes with DNS resolved on the Prontaro node |

> **Always use socks5h://, never socks5://**
>
> Plain `socks5://` resolves DNS locally and sends an IPv4 address to the proxy. Domain rules in the **To** list (such as `api.example.com:443`) then reject the connection. The `h` in `socks5h://` forwards the hostname to the Prontaro node.

## Using `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`

To route multiple CLI tools in one shell session through your static IP, export the standard proxy variables and always exclude local and metadata addresses via `NO_PROXY`:

```bash
export HTTPS_PROXY="$PRONTARO_PROXY_URL"
export HTTP_PROXY="$PRONTARO_PROXY_URL"
export https_proxy="$HTTPS_PROXY"
export http_proxy="$HTTP_PROXY"
export NO_PROXY="localhost,127.0.0.1,::1,169.254.169.254,.internal,.local"
export no_proxy="$NO_PROXY"

# curl picks up the proxy automatically without -x
curl -fsS https://api.ipify.org
```

Exporting lowercase `https_proxy` and `no_proxy` alongside uppercase avoids surprises across tools that only check lowercase names; note that `curl` prefers lowercase `https_proxy` when both are set. To bypass the environment proxy for a single command, pass `--noproxy '*'`.

In production scripts, prefer explicit `-x "$PRONTARO_PROXY_URL"` over global variables so package managers, telemetry, and internal health checks do not consume your Prontaro traffic quota.

## Debugging with `curl -v`: `407` and `403` errors

When application code surfaces a vague `proxy tunnel failed` error, reproduce the request from the same host using `curl -v`. The proxy’s `< HTTP/1.1 ...` response line contains the exact rejection code:

```bash
curl -v -x "$PRONTARO_PROXY_URL" https://api.example.com/v1/health
```

| Proxy status | Cause | Fix |
| --- | --- | --- |
| `407 access_denied` | Wrong password, revoked credentials, or newly created credentials still syncing | Wait 5–10 seconds after creation; verify active credentials under [IP addresses](https://my.prontaro.com/ips) |
| `403 source_denied` | Caller IP is not in the source allowlist | Add the IP under **From** in the credentials’ **Access** tab |
| `403 target_denied` | Destination host/port is not in the **To** list (or `socks5://` resolved DNS locally) | Add `host:port` under **To** in the dashboard (**IP addresses → Proxy credentials → Access**), and verify `socks5h://` |
| `403 destination_denied` | Built-in block: RFC 1918 private ranges, loopback, IPv6, mail ports `25`/`465`/`587` | Target a public IPv4 endpoint on an allowed port |
| `403 volume_exhausted` | Monthly traffic quota reached 100% | Add a traffic pack in the dashboard |
| `429 connection_limit` | Concurrent connection limit per IP exceeded | Reuse keep-alive connections in clients or review [limits](https://prontaro.com/docs/billing/limits.md) |

> **Redact credentials before sharing verbose output**
>
> `curl -v` prints `Proxy-Authorization: Basic ...` in plain Base64. Strip that header before pasting logs into issue trackers or support messages.

## Common issues

- **Unquoted shell variables.** Always quote `-x "$PRONTARO_PROXY_URL"` so shells do not split or expand special characters.
- **Silent failures without `-f`.** Without `-f` (`--fail`), `curl` exits `0` even when the target API returns `403` or `500`.
- **Stale lowercase `https_proxy`.** If an older lowercase `https_proxy` remains in your environment, `curl` uses it instead of `HTTPS_PROXY`. Check with `env | grep -i proxy`.

## Calling an API through a Relay URL

When a script or CI step cannot configure proxy flags, create a Relay for the partner host in the dashboard ([IP addresses](https://my.prontaro.com/ips)) and call it like any normal HTTPS endpoint:

```bash
export PRONTARO_RELAY_URL="https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run"

curl -fsS \
  -H "Authorization: Bearer $PARTNER_API_TOKEN" \
  "$PRONTARO_RELAY_URL/v1/status"
```

If you enabled a password on the Relay (under **IP addresses → Relay address → Access**), pass it in the `Prontaro-Relay-Auth` header. The Prontaro node validates and strips `Prontaro-Relay-Auth` before forwarding the request, leaving your `Authorization: Bearer ...` header intact for the upstream API:

```bash
curl -fsS \
  -H "Prontaro-Relay-Auth: $RELAY_LOGIN:$RELAY_PASSWORD" \
  -H "Authorization: Bearer $PARTNER_API_TOKEN" \
  "$PRONTARO_RELAY_URL/v1/status"
```

See [Relay URLs](https://prontaro.com/docs/outbound/relay.md) for details on TLS termination at the node and HTTP/1.1 behavior.

## Next steps

- [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md) — configure `access` and `targets` allowlists and zero-downtime rotation.
- [Node.js and TypeScript](https://prontaro.com/docs/languages/nodejs.md) — `undici`, `axios`, native `fetch`, and SOCKS5.
- [Python](https://prontaro.com/docs/languages/python.md) — `requests`, `httpx`, and `aiohttp`.
- [PHP](https://prontaro.com/docs/languages/php.md) — Guzzle, native `cURL`, and Laravel.
