diff --git a/.gitignore b/.gitignore index 710df2d..9184ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store /config +tunnel-options.sh diff --git a/Dockerfiles/frontend/nginx.conf b/Dockerfiles/frontend/nginx.conf index b1eb0a5..3dcdc3a 100644 --- a/Dockerfiles/frontend/nginx.conf +++ b/Dockerfiles/frontend/nginx.conf @@ -93,7 +93,7 @@ http { server_name ~^(webtools)(\.\w+)+$; location / { - set $webtools http://plex:33443; + set $webtools http://plex:33442; proxy_pass $webtools; } } diff --git a/open-tunnel.sh b/open-tunnel.sh new file mode 100755 index 0000000..475835a --- /dev/null +++ b/open-tunnel.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +source tunnel-options.sh + +if [[ -z $username ]]; then + username=$USER +fi + +echo "[$0] Connecting and fetching IP..." +echo "[$0] Username: $username" +echo "[$0] Host: $hostname" + +ip=$(ssh -t ${username}@${hostname} "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${container}") + +echo "[$0] IP found: $ip" +echo "[$0] Openning tunnel..." + +open http://localhost:$port && ssh -L $port:$ip:$port ${username}@${hostname} + +echo "[$0] Tunnel closed." + +exit 0 diff --git a/tunnel-options.sh.sample b/tunnel-options.sh.sample new file mode 100644 index 0000000..19e899a --- /dev/null +++ b/tunnel-options.sh.sample @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +################################################################## +# Use : Rename me into "tunnel-options.sh" and change parameters # +################################################################## + +# SSH Host to open tunnel on +hostname="example.com" + +# "UNIX username for SSH access" +username="bob" + +# Plex container name for WebTools IP fetching +container="seedbox_plex_1" + +# Port for WebTools on the container +port=33442