diff --git a/DockerEnv b/DockerEnv index 4f1726f7f..65cab3f6e 100644 --- a/DockerEnv +++ b/DockerEnv @@ -79,3 +79,5 @@ #TRANSMISSION_WATCH_DIR=/data/watch #TRANSMISSION_WATCH_DIR_ENABLED=true #TRANSMISSION_HOME=/data/transmission-home +#WEBPROXY_ENABLED=false +#WEBPROXY_PORT=8888 diff --git a/Dockerfile b/Dockerfile index 9fb6bae3f..e9c765bd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ RUN apt-get update \ && unzip release.zip -d /opt/transmission-ui/ \ && rm release.zip \ && git clone git://github.com/endor/kettu.git /opt/transmission-ui/kettu \ + && apt-get install -y tinyproxy telnet \ && wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb \ && dpkg -i dumb-init_1.2.0_amd64.deb \ && rm -rf dumb-init_1.2.0_amd64.deb \ @@ -29,6 +30,7 @@ RUN apt-get update \ ADD openvpn/ /etc/openvpn/ ADD transmission/ /etc/transmission/ +ADD tinyproxy /opt/tinyproxy/ ENV OPENVPN_USERNAME=**None** \ OPENVPN_PASSWORD=**None** \ @@ -113,8 +115,11 @@ ENV OPENVPN_USERNAME=**None** \ PUID= \ PGID= \ TRANSMISSION_WEB_HOME= \ - DROP_DEFAULT_ROUTE= + DROP_DEFAULT_ROUTE= \ + WEBPROXY_ENABLED=false \ + WEBPROXY_PORT=8888 # Expose port and run EXPOSE 9091 +EXPOSE 8888 CMD ["dumb-init", "/etc/openvpn/start.sh"] diff --git a/README.md b/README.md index aa85c5da7..375e44e85 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,18 @@ As you can see the variables are prefixed with `TRANSMISSION_`, the variable is PS: `TRANSMISSION_BIND_ADDRESS_IPV4` will be overridden to the IP assigned to your OpenVPN tunnel interface. This is to prevent leaking the host IP. +### Web proxy configuration options + +This container also contains a web-proxy server to allow you to tunnel your web-browser traffic through the same OpenVPN tunnel. +This is useful if you are using a private tracker that needs to see you login from the same IP address you are torrenting from. +The default listening port is 8888. Note that only ports above 1024 can be specified as all ports below 1024 are privileged +and would otherwise require root permissions to run. + +| Variable | Function | Example | +|----------|----------|-------| +|`WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true`| +|`WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` | + ### User configuration options By default everything will run as the root user. However, it is possible to change who runs the transmission process. diff --git a/docker-compose-armhf.yml b/docker-compose-armhf.yml index 7369517b1..3e04f2b01 100644 --- a/docker-compose-armhf.yml +++ b/docker-compose-armhf.yml @@ -13,6 +13,7 @@ services: restart: always ports: - "9091:9091" + - "8888:8888" dns: - 8.8.8.8 - 8.8.4.4 @@ -25,7 +26,6 @@ services: - OPENVPN_PASSWORD=password - OPENVPN_OPTS=--inactive 3600 --ping 10 --ping-exit 60 - LOCAL_NETWORK=192.168.0.0/24 - proxy: build: context: ./proxy diff --git a/docker-compose.yml b/docker-compose.yml index 6f0115e5c..f1adbc7c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: restart: always ports: - "9091:9091" + - "8888:8888" dns: - 8.8.8.8 - 8.8.4.4 @@ -21,7 +22,6 @@ services: - OPENVPN_PASSWORD=password - OPENVPN_OPTS=--inactive 3600 --ping 10 --ping-exit 60 - LOCAL_NETWORK=192.168.0.0/24 - proxy: image: haugene/transmission-openvpn-proxy links: diff --git a/openvpn/start.sh b/openvpn/start.sh index 4044cd05c..a9e7a2ef3 100755 --- a/openvpn/start.sh +++ b/openvpn/start.sh @@ -47,7 +47,7 @@ echo $TRANSMISSION_RPC_PASSWORD >> /config/transmission-credentials.txt # Persist transmission settings for use by transmission-daemon dockerize -template /etc/transmission/environment-variables.tmpl:/etc/transmission/environment-variables.sh -TRANSMISSION_CONTROL_OPTS="--script-security 2 --up-delay --up /etc/transmission/start.sh --down /etc/transmission/stop.sh" +TRANSMISSION_CONTROL_OPTS="--script-security 2 --up-delay --up /etc/openvpn/tunnelUp.sh --down /etc/openvpn/tunnelDown.sh" if [ "true" = "$ENABLE_UFW" ]; then # Enable firewall diff --git a/openvpn/tunnelDown.sh b/openvpn/tunnelDown.sh new file mode 100755 index 000000000..371aa024d --- /dev/null +++ b/openvpn/tunnelDown.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +/etc/transmission/stop.sh +/opt/tinyproxy/stop.sh diff --git a/openvpn/tunnelUp.sh b/openvpn/tunnelUp.sh new file mode 100755 index 000000000..5b238ddc2 --- /dev/null +++ b/openvpn/tunnelUp.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +/etc/transmission/start.sh +/opt/tinyproxy/start.sh diff --git a/tinyproxy/start.sh b/tinyproxy/start.sh new file mode 100755 index 000000000..18156e391 --- /dev/null +++ b/tinyproxy/start.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# Source our persisted env variables from container startup +. /etc/transmission/environment-variables.sh + +PROXY_CONF='/etc/tinyproxy.conf' +DEFAULT_PORT=8888 + +set_port() +{ + expr $1 + 0 1>/dev/null 2>&1 + statut=$? + if test $statut -gt 1 + then + echo "Port [$1]: Not a number" >&2; exit 1 + fi + + # Port: Specify the port which tinyproxy will listen on. Please note + # that should you choose to run on a port lower than 1024 you will need + # to start tinyproxy using root. + + if test $1 -lt 1024 + then + echo "tinyproxy: $1 is lower than 1024. Ports below 1024 are not permitted."; + exit 1 + fi + + echo "Setting tinyproxy port to $1"; + sed -i -e"s,^Port .*,Port $1," $2 +} + +if [ "${WEBPROXY_ENABLED}" = "true" ]; then + + echo "STARTING TINYPROXY" + + if [ -z "$WEBPROXY_PORT" ] ; then + set_port ${WEBPROXY_PORT} ${PROXY_CONF} + else + # Always default back to port 8888 + set_port ${DEFAULT_PORT} ${PROXY_CONF} + fi + + /etc/init.d/tinyproxy start + echo "Tinyproxy startup script complete." + +fi diff --git a/tinyproxy/stop.sh b/tinyproxy/stop.sh new file mode 100755 index 000000000..12677c38e --- /dev/null +++ b/tinyproxy/stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ "${WEBPROXY_ENABLED}" = "true" ]; then + + /etc/init.d/tinyproxy stop + +fi diff --git a/transmission/environment-variables.tmpl b/transmission/environment-variables.tmpl index a6545d264..355c1b729 100644 --- a/transmission/environment-variables.tmpl +++ b/transmission/environment-variables.tmpl @@ -81,6 +81,10 @@ export TRANSMISSION_WEB_UI={{ .Env.TRANSMISSION_WEB_UI }} export PUID={{ .Env.PUID }} export PGID={{ .Env.PGID }} +# Need to pass through our tinyproxy settings +export WEBPROXY_ENABLED={{ .Env.WEBPROXY_ENABLED }} +export WEBPROXY_PORT={{ .Env.WEBPROXY_PORT }} + # Support custom web frontend {{ if .Env.TRANSMISSION_WEB_HOME }} export TRANSMISSION_WEB_HOME={{ .Env.TRANSMISSION_WEB_HOME }} {{end}}