← All guides
DEVELOPER GUIDES · 6 MIN READ

Camoufox Proxy Setup: Match Exit Geography to Firefox

Configure a proxy in daijro/camoufox, align GeoIP settings, and validate useful page content from the same browser process.

Camoufox is a Python wrapper around a Firefox based browser. The useful proxy job is keeping the proxy exit, browser locale and timezone consistent while your code loads a permitted page and extracts a known field. This guide refers to daijro/camoufox, the Camoufox project. It is separate from jo-inc/camofox-browser, which is a different product.

The request path is simple: your Python process starts Camoufox, the Camoufox browser sends page traffic through the configured proxy, and the target returns content to that browser. A proxy supplies the route. Your client still owns navigation, rendering, parsing, validation and cleanup.

Install the browser and GeoIP data

Install the GeoIP extra, then fetch the Camoufox browser before running a job:

python -m pip install -U "camoufox[geoip]"
python -m camoufox fetch

Use a provider endpoint in PROXY_SERVER, including its scheme and port. Keep the username and password in the environment or your server’s secret binding. The example deliberately constructs the proxy dictionary at runtime and never prints it.

Run one browser proof

This fixture fails before opening a browser when a required input is missing. It checks the exit IP through the same Camoufox page that will load the target, then requires HTTP 200 and a nonempty target marker. Replace the example URLs and marker with a permitted workload and a field your parser actually needs.

import os
from camoufox.sync_api import Camoufox


REQUIRED = ("PROXY_SERVER", "PROXY_USERNAME", "PROXY_PASSWORD", "TARGET_URL", "EXPECTED_MARKER")
missing = [name for name in REQUIRED if not os.environ.get(name, "").strip()]
if missing:
    raise SystemExit(f"Missing required environment variables: {', '.join(missing)}")

proxy = {
    "server": os.environ["PROXY_SERVER"],
    "username": os.environ["PROXY_USERNAME"],
    "password": os.environ["PROXY_PASSWORD"],
}
target_url = os.environ["TARGET_URL"]
expected_marker = os.environ["EXPECTED_MARKER"].strip()

with Camoufox(geoip=True, proxy=proxy, headless=True) as browser:
    page = browser.new_page()
    page.set_default_timeout(10_000)
    try:
        page.goto("https://api.ipify.org?format=json", wait_until="domcontentloaded", timeout=25_000)
        exit_ip = page.locator("body").inner_text().strip()
        if not exit_ip:
            raise RuntimeError("The same browser client returned no exit-IP body")

        response = page.goto(target_url, wait_until="domcontentloaded", timeout=25_000)
        body = page.locator("body").inner_text()
        if response is None or response.status != 200 or expected_marker not in body:
            raise RuntimeError("Target content validation failed")

        print({"exit_ip_present": bool(exit_ip), "target_url": page.url, "content_valid": True})
    finally:
        page.close()

geoip=True asks Camoufox to derive location, timezone, country and locale from the proxy IP. That alignment is useful when a target expects the browser’s language and clock to agree with the route. Treat it as configuration consistency, not proof that a site will accept the session. If your workload needs a specific locale, set locale deliberately and keep the target’s expected region documented.

Choose the proxy and session policy

Need Proxy choice Session choice Check
Public, stateless page HTTP(S) endpoint New browser per job Required fields pass
Multi-step browser flow Sticky residential or ISP route Keep one browser through the flow Cookies and final record agree
Region-sensitive QA Endpoint with the required exit region One browser per region Exit and locale evidence agree
Repeated independent jobs Provider-supported rotation Separate browser per job Compare valid records and retries

Camoufox’s local Camoufox context gives you one browser instance for this fixture. If you use its remote server mode, read that mode’s current contract separately: the official docs describe one browser instance per server and do not describe automatic fingerprint rotation between sessions. A new browser process is a client lifecycle decision, not a promise of a new proxy identity.

Diagnose the first failing layer

Symptom Likely layer Next test
Missing variable or malformed startup Configuration Check secret bindings and the endpoint scheme without printing credentials
Browser starts, exit-IP page times out Proxy connection Check host, port, protocol and runner reachability
407 or authentication prompt Proxy authentication Confirm the provider’s browser authentication format; see the proxy 407 guide
Exit check works, target marker is absent Target or parser Inspect the returned page, selector and target permissions before changing routes
Multi-step flow changes identity unexpectedly Session policy Keep one browser and use the provider’s sticky-session semantics; see proxy rotation and sticky sessions

Count a Camoufox run only when the required content fields pass. HTTP 200, a non-empty body or an exit IP alone does not prove that the requested record was obtained. Track attempts, retries, transferred bytes and valid records separately with the cost-per-successful-request guide.

Camoufox can help align browser settings with a proxy exit. It does not choose a provider endpoint, guarantee a target response, or replace target-specific permission and parser checks.

Sources and further reading

Sign in ↗

Keep reading

Amazon Scraper API vs Proxy: Choose a Product Data Source

Distinguish authorized Amazon APIs, licensed product data and proxy-based page checks by record quality and access rights.

Read guide →

Apify Custom Proxy Setup: Use Your Own Residential Route

Connect a buyer-owned proxy to an Apify Actor, keep the session boundary clear, and validate records instead of counting requests.

Read guide →

Australia Residential Proxies: Verify the AU Exit and State-Level Result

Separate Australian egress from en-AU content, AUD pricing, GST display, postcode validation and the state delivery context.

Read guide →