How to avoid google chrome proxy bypass for localhost?

12

2

On Linux I'm starting chrome as google-chrome --proxy-server=127.0.0.1:8888 --proxy-bypass-list="" however it's still not using the proxy for localhost requests.

How can I force chrome to use my proxy for localhost?

You may wonder why I wanna do this, I'm trying to record all the requests, using jmeter, to an application running on local environment.

Filipe Giusti

Posted 2019-03-28T23:32:32.073

Reputation: 221

1

Have you checked this question and its answer and comments: https://superuser.com/questions/646304/google-chrome-cant-access-localhost-domains

– music2myear – 2019-03-28T23:40:14.420

And this one: https://stackoverflow.com/questions/30467573/chrome-localhost-does-not-work

– music2myear – 2019-03-28T23:42:17.773

@music2myear thanks for pointing it out, however those are not related to my problem. I can access localhost, I'm trying to access it through a proxy, which seems chrome bypasses it by default without any way to not bypass. – Filipe Giusti – 2019-03-31T20:49:23.697

In your question you are not accessing local host THROUGH a proxy, you are accessing a proxy ON localhost. There is a significant difference, and both those questions deal with proxies on localhost, which is what your question described. Either re-write your question to clarify what you are asking, or re-read the linked questions again. – music2myear – 2019-04-01T15:24:18.003

you are not accessing local host THROUGH a proxy exactly, so how can I make this happen? you are accessing a proxy ON localhost yes, that's correct. Rephrasing, I wanna access a server in localhost through a proxy in localhost. I had re-read the linked questions, they still aren't related to my problem. Please enlighten me, how can I make my question more clear? – Filipe Giusti – 2019-04-02T17:05:00.833

I have the same problem, none of the above links helped. The local machine is Windows, the remote is Ubuntu. The proxy connection is tunneled through SSH. I can access the remote 127.0.0.1 using curl --proxy on the local Windows machine, but on the same machine neither Firefox nor Chrome can access the remote 127.0.0.1 through the proxy. The interesting thing is that this worked some moths ago, then stopped working. First I though it's an issue with the remote server, but since the local curl --proxy works I'm sure it's a browser or OS problem. – Crouching Kitten – 2019-06-15T23:23:01.753

Answers

5

Finally I've found a tricky solution for this. It was clear from the beginning that this is a browser issue, since I was able to make requests with curl --proxy.

The trick is that the DNS resolution also happens through the proxy, therefore on the remote machine. So just add a new entry to your remote /etc/hosts file:

127.0.0.1       local

Then you can access the remote "localhost" on your local machine, since Chrome knows nothing about this new host name. For example by: http://local:8080/mysite.

Crouching Kitten

Posted 2019-03-28T23:32:32.073

Reputation: 151

I had the same problem and I confirm that this solution works (using Chromium 73 on Kali Linux). – countermode – 2019-07-05T12:52:04.993

5

chrome.exe --proxy-server="socks5://localhost:12345" --proxy-bypass-list="<-loopback>"

this will work for localhost,127.0.0.1,127.0.0.2(have not tested, but assume),etc...

https://bugs.chromium.org/p/chromium/issues/detail?id=899126#c18

Brenda.ZMPOV

Posted 2019-03-28T23:32:32.073

Reputation: 61

you are the best! this works perfectly :) – Sindhu S – 2019-08-01T13:11:14.370

1doesn't work for me on Chromium 77.0.3865.90 on Arch linux – Gregor Sturm – 2019-10-01T07:30:04.783

Doesn't work for me using MacOS. I've read this does work for Windows, however – Fixee – 2019-11-18T00:23:54.117