Skip to content

Instantly share code, notes, and snippets.

@noelbundick
Last active February 4, 2024 15:35
Show Gist options
  • Save noelbundick/be9bf7bcaa6c6bcee4b65da841c620a3 to your computer and use it in GitHub Desktop.
Save noelbundick/be9bf7bcaa6c6bcee4b65da841c620a3 to your computer and use it in GitHub Desktop.
Azure Container Instances as SOCKS proxy

Azure Container Instances as SOCKS proxy

Sometimes it's useful to originate traffic from a specific region - etc to test global load balancers, DNS, etc. A common way to do this is to SSH to some remote VPN service or VM, then forward your traffic through that remote endpoint.

You can also use this to watch Netflix outside of your current country while traveling abroad :P

Azure Container Instances are a quick & easy way to do this as well - launch the ssh daemon in a container, expose port 22, and start forwarding traffic!

Check out the regions you can forward traffic on the Products available by region page

How to use

Follow the steps in proxy.sh

Why this is a gist

I've not changed the default root:root password, and I'm exposing port 22. Please secure your ssh daemon and don't use this as-is in a production environment

Extra credit

You probably don't want to leave your proxy container running in case you forget. Use my self-destruct CLI extension to have it automatically clean itself up after N hours!

MIT License
Copyright (c) 2018 Noel Bundick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
#!/bin/bash
# Create a container in Azure in the region you want
az group create -n temp-proxy -l southcentralus
az container create -g temp-proxy -n proxy --image rastasheep/ubuntu-sshd --ip-address Public --ports 22 --dns-name-label myproxy
ssh -D 1337 -C -N root@myproxy.southcentralus.azurecontainer.io
# Go to your network connection, set your SOCKS proxy to localhost:1337
# Browse around, your traffic is being tunneled through southcentralus
# When you're done, unset your proxy
# Clean up
az group delete -n temp-proxy -y --no-wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment