Open
Description
Version
1.52.0
Steps to reproduce
import asyncio
import json
from playwright.async_api import async_playwright
TEST_URL = "https://api.ipify.org?format=json"
PROXY = {
"server": "http://proxy_url:proxy_port",
"username": "username",
"password": "password",
}
async def fetch_ip(context):
page = await context.new_page()
await page.goto(TEST_URL, wait_until="domcontentloaded")
ip = json.loads(await page.text_content("body"))["ip"]
await context.close()
return ip
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
headless=True,
proxy={"server": "per-context"}, # <-- required
args=["--disable-blink-features=AutomationControlled"],
)
ctx1 = await browser.new_context(proxy=PROXY)
print("CTX-1 IP ⇒", await fetch_ip(ctx1))
await browser.close()
asyncio.run(main())
Expected behavior
CTX-1 IP ⇒ <IP-from-proxy>
Actual behavior
CTX-1 ⇒ <host-public-IP>
Additional context
When Chromium is launched with proxy={"server": "per-context"} inside a Docker container, no context created with browser.new_context(proxy=…) uses the proxy at all—all requests always fall back to the container’s outbound IP.
Environment
- Operating System: [Ubuntu 22.04]
- CPU: [amd64]
- Browser: [Chromium]
- Python Version: [3.12]
- Docker img: mcr.microsoft.com/playwright/python:v1.52.0-noble
- Other info:
Metadata
Metadata
Assignees
Labels
No labels