Seanonymous
Seanonymous

Reputation: 1384

BrowserMob not proxying localhost pages

I'm trying to use BrowserMob to proxy pages with Selenium WebDriver. When the (Python) test case tries to load pages from localhost, BrowserMob fails to proxy them.

Is it possible for BrowserMob to proxy connections to the webserver at localhost?

Upvotes: 1

Views: 1227

Answers (2)

feser
feser

Reputation: 51

I had the same problem with Selenium ChromeDriver. It didn't use proxy for localhost.
Setting noProxy attribute of seleniumProxy to "<-loopback>" solved the issue.

val seleniumProxy = ClientUtil.createSeleniumProxy(this)
...
seleniumProxy.noProxy = "<-loopback>"

Take a look at below link for details. https://chromium.googlesource.com/chromium/src/+/master/net/docs/proxy.md#bypass-rule_subtract-implicit-rules

Upvotes: 3

Jason Hoetger
Jason Hoetger

Reputation: 8127

BrowserMob Proxy will work with localhost, but only in the latest version (2.0.0), and only when defining the bmp.allowNativeDnsFallback Java property when running the proxy. I'm not familiar with the Python wrapper, but it's unlikely that it meets those criteria.

The problem is the DNS resolution that BrowserMob Proxy uses, which essentially ignores the hosts file that defines localhost. If you use 127.0.0.1 instead of localhost when making requests it should work for you.

Upvotes: 1

Related Questions