6

I am utilizing Google Chrome as a port forward via SOCKS proxy.

Essentially I am running the following command via terminal: ssh foo@bar.com -D 9999

Then in Google Chrome, I set the SOCKS proxy to 127.0.0.1:9999.

Problem is, I need to then access the host of https://localhost/foo/bar to be able to access what I need to access. This works fine on Firefox (when I modify the proxy settings), but not on Chrome.

If I go into /etc/hosts on my system and create an entry like this:

127.0.0.1 foobar

I can then go to https://foobar/foo/bar and everything works fine. It seems that chrome refuses to forward localhost or 127.0.0.1. Is there any way around this?

hanxue
  • 2,940
  • 4
  • 29
  • 53
bdf0506
  • 61
  • 1
  • 3
  • [A similar question is here](https://superuser.com/questions/1418848/how-to-avoid-google-chrome-proxy-bypass-for-localhost), with similar suggested workarounds. – Dan R Aug 29 '19 at 04:01

2 Answers2

3

By default, Chrome 72+ will NOT send localhost requests through your configured proxy.

You need to configure Chrome's proxy bypass list to contain <-loopback>, which is a special option that tells it to send localhost through the proxy.

Via command line, this looks like:

google-chrome --proxy-server=socks://127.0.0.1:9999 --proxy-bypass-list='<-loopback>'

Dan R
  • 103
  • 3
  • 1
    Some more info: The [source code](https://chromium.googlesource.com/chromium/src/+/refs/heads/master/net/proxy_resolution/proxy_bypass_rules.cc#16) has a special case for the exact text string `<-loopback>`. According to a comment in the source code, the meaning is: _Remove the implicitly added bypass rules_ – Erik Sjölund Feb 19 '20 at 17:39
0

I have similar problem.(but I used SwitchyOmega, didn't know chrome already can use socks in build-in settings). At least, heading for my question could be the same.

Sometimes I use proxy ssh tunnel to access ports which are only acessible from server itself.

But Chrome started to ignore proxy settings for localhost so I had to search for workarounds too.

Currentl solution is to use wildcard dns services. Example links to localhost: http://127.0.0.1.nip.io, http://127.0.0.1.xip.io

quant2016
  • 131
  • 4