Skip to content

jmarhee/terraform-linode-proxy

Repository files navigation

SOCKS Proxy Server on Linode

Build Status

Deploys a nanode instance on Linode via Terraform for use as an SSH tunnel SOCKS v5 proxy server.

Setup

Get your Linode API token, and set linode_token to this value in terraform.tfvars or on first-run.

Run:

terraform init

then:

terraform plan
terraform apply -auto-approve

to deploy the proxy host, and setup the tunnel. You can, then, set the proxy address in your browser.

Usage

Specify a browser_command, if you wish to launch your browser using the proxy on completion:

browser_command = "open -a '/Applications/Google Chrome.app' --args --incognito"
set_osx_proxy   = true

for Safari users, you can use:

browser_command = "osascript -e 'tell application \"Safari\" to activate' -e 'delay 0.5' -e 'tell application \"System Events\" to keystroke \"N\" using {command down, shift down}'"

to open a private browser window.

If you are on OS X, you can use the set_osx_proxy option above to enable the proxy before launching the browser as well. Otherwise, all_proxy is set when the browser_command is run (which sets the proxy on most Linux systems).

Verifying

To test this manually, in your browser, use the address http://127.0.0.1:8888 to direct client traffic through your proxy host.

You can find directions for common web browsers here for configuring a SOCKS proxy.

You can test this yourself (which is also the last step in the module, which you'll see in the Terraform output) by running:

curl -s --socks5-hostname http://127.0.0.1:8888 -L http://ipinfo.io/json

to confirm your HTTP traffic is going through the proxy host.

Troubleshooting

The output will include your host address:

Outputs:

Tunnel_Host = Set SOCKSv5 host to:
        127.0.0.1:8888
in order to proxy through xx.xx.xx.xx

This latter address will be your host address on Linode, which you can check to confirm is online and troubleshoot connectivity further.

If, on OS X, the node launches properly and there is an ssh process active, but you have not been connected to the proxy, run:

USER=root HOST=${output_host_ip} scripts/proxy_status.sh

If you are on OS X, and after destroy, you are receiving an error indicating the proxy is no longer available, you may need to manually deconfigure the proxy configuration by running:

networksetup -setsocksfirewallproxystate wi-fi off

on your local machine.