> ## Documentation Index
> Fetch the complete documentation index at: https://instabox.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use a residential IP with your own proxy

> Send a machine's outbound traffic through a residential, mobile, or static proxy that you buy, so sites stop blocking its datacenter address.

A machine reaches the internet from a datacenter address, and some sites block those addresses or
answer them with a CAPTCHA. To reach such a site, send the machine's traffic through a proxy of your
own. The site then sees the proxy's address and not the machine's. Use a proxy when a browser agent or
a scraper in a machine gets blocked, or when a service must see one fixed address from you.

InstaBox does not sell or include residential IPs. You buy the proxy from a provider of your choice,
and this page shows how to point the tools in a machine at it.

```bash theme={null}
instabox exec scraper -- \
  'curl -s -x "$PROXY_URL" https://checkip.amazonaws.com'
```

## Why a site blocks a machine

A machine's outbound IPv4 traffic leaves from the public address of the host it runs on. Every machine
on that host shares the address, including machines of other accounts. The address belongs to a cloud
or datacenter provider, and sites that fight bots often refuse such addresses whatever the request
looks like.

The address can also change, because a machine may start or resume on another host. InstaBox has no
fixed or dedicated outbound address for a machine, so a proxy is also the way to get one.

On some hosts a machine also has a public IPv6 address of its own. A request that does not go through
the proxy can leave from that address when the site supports IPv6, and so can WebRTC.

## Choose a proxy

Pick the kind of proxy by what the site checks. This table lists the common kinds.

| Kind | The site sees | Use it when |
| - | - | - |
| Residential | A home internet address, often a new one for each session | A site blocks datacenter addresses |
| ISP (static residential) | One address that an internet provider owns and that stays the same | A login session must keep one address |
| Mobile | A mobile carrier address | A site trusts only mobile traffic |
| Static datacenter | One fixed datacenter address | A service must allowlist your address |

Ask the provider for two things:

* **Username and password sign-in.** Do not use the provider's IP allowlist for the machine's address,
  because the machine shares that address with other accounts and the address can change.
* **An HTTP proxy endpoint.** Every tool on this page works with one. A SOCKS5 endpoint also works with
  curl. Python needs an extra package for SOCKS5, `requests[socks]` or `httpx[socks]`. Chromium cannot
  sign in to a SOCKS5 proxy.

The examples use `http://USER:PASS@proxy.example.com:8080` as the proxy URL. Put your provider's host,
port, username, and password in its place.

## Save the proxy URL as a Secret

The proxy URL holds your proxy password, so keep it out of your code and your shell history. Save it
as a [direct Secret](https://instabox.sh/docs/security/direct-secrets.md), which puts the real value in the machine as an
environment variable. The CLI prompts for the value without echo.

```bash theme={null}
instabox secrets set PROXY_URL --direct
```

Then reference the Secret when you create the machine. Every login shell in the machine (`exec`, SSH,
the dashboard terminal) then has the variable `PROXY_URL`.

```bash theme={null}
instabox create --name scraper --secret-env PROXY_URL
```

For a machine that already exists, run `instabox secrets select scraper --secret-env PROXY_URL`.

## Check the address a site sees

Ask a service that answers with the caller's address, first without the proxy and then through it.
The first command prints the machine's datacenter address.

```bash theme={null}
instabox exec scraper -- curl -s https://checkip.amazonaws.com
```

The second command sends the same request through the proxy with curl's `-x` option. It prints an
address of your proxy provider.

```bash theme={null}
instabox exec scraper -- \
  'curl -s -x "$PROXY_URL" https://checkip.amazonaws.com'
```

If both commands print the same address, the request did not go through the proxy.

## Point a tool at the proxy

Give the proxy to the one tool that needs it. Your other traffic, such as package installs and model
API calls, then stays off the proxy, which most providers bill by the gigabyte.

### Python

`requests` and `httpx` both take the proxy URL in code. Neither is preinstalled, so install the one
you use into a virtual environment first. This example uses `requests`.

```python theme={null}
import os
import requests

proxy = os.environ["PROXY_URL"]
r = requests.get(
    "https://checkip.amazonaws.com",
    proxies={"http": proxy, "https": proxy},
    timeout=30,
)
print(r.text)
```

With `httpx`, pass the URL as `proxy` when you make the client.

```python theme={null}
import os
import httpx

with httpx.Client(proxy=os.environ["PROXY_URL"]) as client:
    print(client.get("https://checkip.amazonaws.com").text)
```

### Node.js

Node's built-in `fetch` takes a proxy as a `dispatcher`. Install `undici` in your project, and pass
its `ProxyAgent` with the request.

```js theme={null}
import { ProxyAgent, fetch } from 'undici'

const dispatcher = new ProxyAgent(process.env.PROXY_URL)
const res = await fetch('https://checkip.amazonaws.com', { dispatcher })
console.log(await res.text())
```

### Playwright

Install `playwright` in your project, then run `npx playwright install chromium` to download its
Chromium. To use the template's Chromium and skip the download, add
`executablePath: '/usr/bin/chromium'` to the launch options.

Playwright takes the proxy's address, username, and password as separate fields, so split the URL.
The two `args` keep WebRTC behind the proxy, as
[Keep WebRTC behind the proxy](#keep-webrtc-behind-the-proxy) explains.

```js theme={null}
import { chromium } from 'playwright'

const proxy = new URL(process.env.PROXY_URL)
const browser = await chromium.launch({
  proxy: {
    server: proxy.origin,
    username: decodeURIComponent(proxy.username),
    password: decodeURIComponent(proxy.password),
  },
  args: [
    '--webrtc-ip-handling-policy=disable_non_proxied_udp',
    '--force-webrtc-ip-handling-policy=disable_non_proxied_udp',
  ],
})
const page = await browser.newPage()
await page.goto('https://checkip.amazonaws.com')
console.log(await page.innerText('body'))
await browser.close()
```

To keep some hosts off the proxy, add `bypass` to `proxy`, for example `bypass: 'api.example.com'`.

### Chromium

When you start Chromium yourself, pass the proxy with `--proxy-server`. The flag takes the address
only.

```bash theme={null}
chromium --proxy-server=http://proxy.example.com:8080
```

Chromium does not read a username and password from the flag. With `USER:PASS@` in the flag, every
page fails with `ERR_NO_SUPPORTED_PROXIES`. For a proxy that needs a sign-in, start the browser from
Playwright as above, which answers the proxy's sign-in for you.

## Send all of a shell's traffic through the proxy

Most command-line tools read the proxy from environment variables, so you can set them once for a
shell and not pass the proxy to each tool. Set both the upper-case and the lower-case names, because
tools differ in which ones they read. curl, for example, reads `http_proxy` only in lower case.

```bash theme={null}
export HTTP_PROXY="$PROXY_URL" HTTPS_PROXY="$PROXY_URL"
export http_proxy="$PROXY_URL" https_proxy="$PROXY_URL"
```

Then list the hosts that must stay off the proxy in `NO_PROXY`, separated by commas.

```bash theme={null}
export NO_PROXY=localhost,127.0.0.1,api.example.com
export no_proxy="$NO_PROXY"
```

curl, `requests`, and `httpx` read these variables. Node.js reads them only when you also set
`NODE_USE_ENV_PROXY=1`, which Node.js 22 in the templates supports. Node.js then prints a warning
that `EnvHttpProxyAgent` is experimental.

```bash theme={null}
export NODE_USE_ENV_PROXY=1
```

Chromium reads the variables too, but it cannot use the username and password in them, so no page
loads. The template's Chromium fails with `ERR_INVALID_AUTH_CREDENTIALS`, and the Chromium that
Playwright downloads waits until the page load times out. Give a browser its proxy from Playwright.

> [!WARNING]
>
> With these variables set, package installs, git over HTTPS, and coding agents in that shell also use
> the proxy. That traffic counts toward your provider's bill.

## Keep Org Secrets working

[Org Secrets](https://instabox.sh/docs/security/secrets.md) replaces a placeholder with the real credential only in HTTPS
requests that go straight from the machine to an allowed host. A request that goes through your proxy
is hidden inside the connection to the proxy, so the placeholder is not replaced. The API then
receives `ibsec_...` and refuses it, usually with `401`.

If a machine uses Org Secrets, keep each Secret's hosts off your proxy. When you give the proxy to one
tool, as under [Point a tool at the proxy](#point-a-tool-at-the-proxy), the other tools are not
affected. When you set the variables for a whole shell, add every Secret host to `NO_PROXY`.

```bash theme={null}
export NO_PROXY=localhost,127.0.0.1,api.anthropic.com,api.github.com
```

On such a machine, also choose a proxy endpoint on a port other than 443. Org Secrets handles all of
the machine's TCP traffic to port 443 and expects HTTPS there, so it closes a connection to an HTTP or
SOCKS5 proxy on that port.

## Keep WebRTC behind the proxy

A proxy carries a browser's HTTP and HTTPS traffic. WebRTC sends UDP packets straight from the machine
by default, and a page can use them to learn the machine's real address. To make Chromium keep WebRTC
behind the proxy, start it with these two flags. Pass both, because Chromium builds differ in which
one they read. The template's Chromium reads the first, and the Chromium that Playwright downloads
reads the second.

```bash theme={null}
chromium --proxy-server=http://proxy.example.com:8080 \
  --webrtc-ip-handling-policy=disable_non_proxied_udp \
  --force-webrtc-ip-handling-policy=disable_non_proxied_udp
```

Other programs that send UDP, such as a game client or a VPN, do not use an HTTP proxy at all.

## Limits

> [accordion] DNS lookups do not go through the proxy by default
>
> With an HTTP proxy, the proxy looks up the name of the site, so the machine's resolver never sees
> it. With a SOCKS5 proxy, write the URL as `socks5h://` so that the proxy looks the name up. With
> `socks5://`, the machine looks the name up itself.
>
> The machine always looks up the proxy's own hostname itself. InstaBox answers a machine's DNS
> queries on port 53 with its own resolver, whatever resolver the machine names. It blocks DNS over
> TLS on port 853, and DNS over HTTPS to well-known public resolvers such as `1.1.1.1` and `8.8.8.8`.

> [accordion] Connections, bandwidth, and ports
>
> The machine's own limits still apply to the traffic it sends to your proxy.
>
> * A machine can open 50 new outbound connections each second, with a burst of 200, and hold 1024
>   open at once. A connection over the limit is dropped, so it times out. A crawler that opens one
>   proxy connection for each request can reach this limit.
> * What a machine sends is capped at 50 Mbit/s after a burst. See "Outbound bandwidth" on
>   [Limits](https://instabox.sh/docs/account/limits.md).
> * The free plan drops connections to some TCP ports. Four of them are common proxy ports: 1080,
>   3128, 3129, and 7777. If a connection to your proxy times out on the free plan, use an endpoint
>   of your provider on another port, such as 8080.
> * The proxy must have a public address. A machine cannot reach private addresses such as
>   `10.0.0.0/8` or `192.168.0.0/16`.

> [accordion] What a proxy does not change
>
> A proxy changes the address a site sees. It does not change the browser's fingerprint, its
> cookies, or how fast it clicks, and a site can still block an automated browser for those.
> Your provider bills the traffic you send through the proxy, usually by the gigabyte. That includes
> the requests Chromium makes on its own, such as its update checks.

## Acceptable use

Sending your own traffic out through a proxy is allowed on every plan. Two rules of the
[Terms](https://instabox.sh/terms) still apply:

* **Respect the sites you visit.** Do not use a proxy to break a site's terms of use, to get around
  its technical limits, or to scrape personal data.
* **Do not turn the machine into a proxy.** On the free plan, a machine may not run a proxy or VPN
  server that carries general internet traffic. On every plan, a machine may not serve as an open
  proxy or relay for other people.

> [card] [Computer use](https://instabox.sh/docs/access/computer-use.md)
>
> Have a model drive a browser on a machine's desktop.

> [card] [Org Secrets](https://instabox.sh/docs/security/secrets.md)
>
> Credentials a machine sees only as placeholders.
