Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BrowserMob proxy and hosts file

I'm trying to use BrowserMob proxy to monitor requests sent by WebDriver(Selenium) browser.

I instantiate proxy with:

    server = new ProxyServer(localProxyPort);       
    server.start();

Then I create Firefox profile which would use this proxy:

    FirefoxProfile profile = new FirefoxProfile(); 

    profile.setPreference("network.proxy.type", 1);
    profile.setPreference("network.proxy.http", "localhost");
    profile.setPreference("network.proxy.http_port", localProxyPort);      

My problem is that I have a LOT of different host mapping in my 'hosts' file. BrowserMob proxy ignores system hosts file, and tries to resolve ips by itself.

There is a solution:

    server.remapHost("somehost.com", "127.0.0.1");

But I cant do it for every host. Is there a way to force proxy to use my system hosts mappings?

Thanks!

Leonti

like image 250
Leonti Avatar asked Dec 11 '25 01:12

Leonti


1 Answers

We can have several hosts re-mapping using the same function:

server.remapHost("somehost.com", "127.0.0.1");
server.remapHost("someotherhost.com", IP Address);
like image 158
user2220762 Avatar answered Dec 13 '25 23:12

user2220762



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!