I wrote this blog post originally in 2017 on my earlier blog. I updated the commands and tested that they work in 2024 too.
Today I needed to connect into web service which was only available remote server and not exposed to the public internet. This short guide teaches you to how to debug http services with chrome in remote environment. You can also use it if you want your IP-address to show up elsewhere.
For example I had a http server which was only available in remote environment but simultaneously I needed to access things running from
localhost
.
Here are the commands that you need:# Open socks5 proxy to local port 1337 # This connects to remote host using default ssh port 22 # Leave the terminal window open after the command since this runs in foreground $ ssh -D 1080 -C -q -N user@server -p 22 # Then in other terminal window you can run # Open a new chrome instance using the local socks5 proxy $ open -n -a "Google Chrome" --args \ --proxy-server="socks5://127.0.0.1:1080" \ --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" \ --user-data-dir=$(mktemp -d) \ --no-first-run \ --no-default-browser-check \ --incognito
After this new chrome window opens and all requests except
localhost
are resolved through the remote machine. You can test this by visiting eg https://www.whatismyip.com/ in the new Chrome window.
Now you can browse the internet and remote services through your remote server.