The essential points from this guide -- each one is explained in detail below.
Chrome: add --proxy-server=host:port to ChromeOptions arguments for unauthenticated proxies.
For authenticated proxies, create a Chrome extension that supplies credentials via chrome.webRequest.
Selenium Wire replaces the standard webdriver and handles proxy auth, HTTPS interception, and request logging.
Firefox supports proxy config through profile preferences for HTTP, HTTPS, and SOCKS independently.
The simplest way to proxy Selenium Chrome is the --proxy-server launch argument. This routes all browser traffic through the specified proxy server. It works with unauthenticated proxies and does not require any additional packages.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--proxy-server=gw.knoxproxy.com:7000')
driver = webdriver.Chrome(options=options)
driver.get('https://httpbin.org/ip')
print(driver.page_source)
driver.quit()This approach has one limitation: it does not support proxy authentication. Chrome ignores the username:password@ portion of the proxy argument. For authenticated proxies like KnoxProxy's gateway, you need either a Chrome extension or Selenium Wire.
To use authenticated proxies in Selenium Chrome, create a lightweight extension that intercepts the proxy authentication challenge and supplies credentials. This is the standard workaround for Chrome's lack of command-line proxy auth support.
import zipfile
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def create_proxy_extension(proxy_host, proxy_port, proxy_user, proxy_pass):
manifest = '''{"version":"1.0.0","manifest_version":2,"name":"Proxy Auth","permissions":["proxy","tabs","unlimitedStorage","storage","<all_urls>","webRequest","webRequestBlocking"],"background":{"scripts":["background.js"]}}'''
background = f'''chrome.webRequest.onAuthRequired.addListener(function(details){{return{{authCredentials:{{username:"{proxy_user}",password:"{proxy_pass}"}}}}}},{{urls:["<all_urls>"]}},["blocking"]);
chrome.proxy.settings.set({{value:{{mode:"fixed_servers",rules:{{singleProxy:{{host:"{proxy_host}",port:{proxy_port}}}}}}},scope:"regular"}});'''
ext_path = '/tmp/proxy_auth.zip'
with zipfile.ZipFile(ext_path, 'w') as zp:
zp.writestr('manifest.json', manifest)
zp.writestr('background.js', background)
return ext_path
ext = create_proxy_extension('gw.knoxproxy.com', 7000, 'USER', 'PASS')
options = Options()
options.add_extension(ext)
driver = webdriver.Chrome(options=options)
driver.get('https://httpbin.org/ip')The extension runs in the background and responds to Chrome's 407 proxy authentication challenges automatically. This approach works with both headful and headless Chrome, though headless mode requires the --headless=new flag in recent Chrome versions.
Selenium Wire is a drop-in replacement for Selenium's webdriver that adds proxy authentication, request interception, and HTTPS decryption. It is the easiest way to use authenticated proxies with Selenium since it handles all the complexity internally.
from seleniumwire import webdriver
options = {
'proxy': {
'http': 'http://USER:PASS@gw.knoxproxy.com:7000',
'https': 'http://USER:PASS@gw.knoxproxy.com:7000',
}
}
driver = webdriver.Chrome(seleniumwire_options=options)
driver.get('https://httpbin.org/ip')
# Access intercepted requests
for request in driver.requests:
if request.response:
print(request.url, request.response.status_code)
driver.quit()Selenium Wire works by running a local proxy that intercepts all browser traffic, adds the upstream proxy credentials, and forwards the requests. This means it adds a small amount of latency compared to native proxy support, but the convenience is significant for development and debugging.
Firefox supports proxy configuration through profile preferences, which gives you fine-grained control over HTTP, HTTPS, and SOCKS proxy settings independently. Firefox also supports proxy authentication natively through the network.http.phishing-warning preference.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.http', 'gw.knoxproxy.com')
profile.set_preference('network.proxy.http_port', 7000)
profile.set_preference('network.proxy.ssl', 'gw.knoxproxy.com')
profile.set_preference('network.proxy.ssl_port', 7000)
profile.set_preference('network.proxy.no_proxies_on', 'localhost,127.0.0.1')
options.profile = profile
driver = webdriver.Firefox(options=options)
driver.get('https://httpbin.org/ip')The proxy type value of 1 means manual proxy configuration. Firefox will prompt for credentials on the first request if authentication is required. For headless automation, use Selenium Wire to handle authentication without the prompt.
Ready to put this into practice? Browse Residential Proxies
KnoxProxy Research Team · Technical Content
Network engineers and proxy infrastructure specialists with 10+ years in anti-bot systems, web scraping, and IP routing.
90.4M+ ethically sourced residential IPs across 195 countries. Start free -- no credit card required.