14

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.

  • 1
    Have you checked this question and its answer and comments: superuser.com/questions/646304/… – music2myear Mar 28 '19 at 23:40
  • And this one: stackoverflow.com/questions/30467573/… – music2myear Mar 28 '19 at 23:42
  • @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 Mar 31 '19 at 20:49
  • 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 Apr 1 '19 at 15:24
  • 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 Apr 2 '19 at 17:05
6

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.

| improve this answer | |
  • I had the same problem and I confirm that this solution works (using Chromium 73 on Kali Linux). – countermode Jul 5 '19 at 12:52
6
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

| improve this answer | |
  • you are the best! this works perfectly :) – Sindhu S Aug 1 '19 at 13:11
  • 1
    doesn't work for me on Chromium 77.0.3865.90 on Arch linux – Gregor Sturm Oct 1 '19 at 7:30
  • Doesn't work for me using MacOS. I've read this does work for Windows, however – Fixee Nov 18 '19 at 0:23
1

For Windows10, this is a System issue, that localhost will always goto current PC, and won't go through proxy.

U can set this in the OS's proxy setting to force localhost go proxy.

  • Open the OS's proxy setting
  • Ensure your proxy server(host & port) are set.
  • Below, there will be a input for you, says Use the proxy server except for address that start with the following entries. Use semicolons(;) to separate entries
  • Add <-loopback> into that input.
  • Save.

Then your request of localhost to go under proxy.

Note:

  • Though broswers will bypass localhost by default, the CMD will work even without this setting. curl -x http://{proxyserIp}:{proxyPort} http://localhost:3000
  • If u r using some browser extension(like SwitchyOmega), u can also add <-loopback into it's Bypass list, this still works.

refer: https://docs.microsoft.com/en-us/archive/blogs/fiddler/fiddler-and-the-ie9-release-candidate https://stackoverflow.com/questions/37700079/how-to-intercept-local-server-web-requests-using-burp-in-internet-explorer

| improve this answer | |
0

If you are using mitmproxy or charles to debug localhost requests, try using Chrome 69 in macos with system proxy set.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.