diff --git a/DockerEnv b/DockerEnv index ef6310375..c783ec2f7 100644 --- a/DockerEnv +++ b/DockerEnv @@ -75,4 +75,6 @@ #TRANSMISSION_UTP_ENABLED=true #TRANSMISSION_WATCH_DIR=/data/watch #TRANSMISSION_WATCH_DIR_ENABLED=true -#TRANSMISSION_HOME=/data/transmission-home \ No newline at end of file +#TRANSMISSION_HOME=/data/transmission-home +#WEBPROXY_ENABLED=true +#WEBPROXY_PORT=8888 \ No newline at end of file diff --git a/README.md b/README.md index 32016b4fd..bd51bee3d 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,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 fb4583750..ea8e79fe3 100644 --- a/docker-compose-armhf.yml +++ b/docker-compose-armhf.yml @@ -10,6 +10,7 @@ services: restart: always ports: - "9091:9091" + - "8888:8888" dns: - 8.8.8.8 - 8.8.4.4 @@ -22,7 +23,8 @@ services: - OPENVPN_PASSWORD=password - OPENVPN_OPTS=--inactive 3600 --ping 10 --ping-exit 60 - LOCAL_NETWORK=192.168.0.0/24 - + - WEBPROXY_ENABLED=true + - WEBPROXY_PORT=8888 proxy: build: context: ./proxy diff --git a/docker-compose.yml b/docker-compose.yml index a0d169ab0..13de835a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: restart: always ports: - "9091:9091" + - "8888:8888" dns: - 8.8.8.8 - 8.8.4.4 @@ -18,7 +19,8 @@ services: - OPENVPN_PASSWORD=password - OPENVPN_OPTS="--inactive 3600 --ping 10 --ping-exit 60" - LOCAL_NETWORK=192.168.0.0/24 - + - WEBPROXY_ENABLED=true + - WEBPROXY_PORT=8888 proxy: image: haugene/transmission-openvpn-proxy links: diff --git a/openvpn/start.sh b/openvpn/start.sh index 0c5812755..d42655b0b 100755 --- a/openvpn/start.sh +++ b/openvpn/start.sh @@ -54,7 +54,15 @@ if [ -n "${LOCAL_NETWORK-}" ]; then fi fi -/opt/tinyproxy/run.sh ANY -/etc/init.d/tinyproxy start + +if [ "${WEBPROXY_ENABLED}" = "true" ]; then + if [ -z "$WEBPROXY_PORT" ] ; then + /opt/tinyproxy/setport.sh $WEBPROXY_PORT + else + # Alway default back to port 8888 + /opt/tinyproxy/setport.sh 8888 + fi + /etc/init.d/tinyproxy start +fi exec openvpn $TRANSMISSION_CONTROL_OPTS $OPENVPN_OPTS --config "$OPENVPN_CONFIG" diff --git a/tinyproxy/run.sh b/tinyproxy/run.sh deleted file mode 100755 index 76eb34171..000000000 --- a/tinyproxy/run.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash - -# Global vars -PROG_NAME='DockerTinyproxy' -PROXY_CONF='/etc/tinyproxy.conf' -TAIL_LOG='/var/log/tinyproxy/tinyproxy.log' - -# Usage: screenOut STATUS message -screenOut() { - timestamp=$(date +"%H:%M:%S") - - if [ "$#" -ne 2 ]; then - status='INFO' - message="$1" - else - status="$1" - message="$2" - fi - - echo -e "[$PROG_NAME][$status][$timestamp]: $message" -} - -# Usage: checkStatus $? "Error message" "Success message" -checkStatus() { - case $1 in - 0) - screenOut "SUCCESS" "$3" - ;; - 1) - screenOut "ERROR" "$2 - Exiting..." - exit 1 - ;; - *) - screenOut "ERROR" "Unrecognised return code." - ;; - esac -} - -stopService() { - screenOut "Checking for running Tinyproxy service..." - if [ "$(pidof tinyproxy)" ]; then - screenOut "Found. Stopping Tinyproxy service for pre-configuration..." - killall tinyproxy - checkStatus $? "Could not stop Tinyproxy service." \ - "Tinyproxy service stopped successfully." - else - screenOut "Tinyproxy service not running." - fi -} - -parseAccessRules() { - list='' - for ARG in $@; do - line="Allow\t$ARG\n" - list+=$line - done - echo "$list" | sed 's/.\{2\}$//' -} - -setMiscConfig() { - sed -i -e"s,^MinSpareServers ,MinSpareServers\t1 ," $PROXY_CONF - checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \ - "Set MinSpareServers - Edited $PROXY_CONF successfully." - - sed -i -e"s,^MaxSpareServers ,MaxSpareServers\t1 ," $PROXY_CONF - checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \ - "Set MinSpareServers - Edited $PROXY_CONF successfully." - - sed -i -e"s,^StartServers ,StartServers\t1 ," $PROXY_CONF - checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \ - "Set MinSpareServers - Edited $PROXY_CONF successfully." -} - -enableLogFile() { - touch /var/log/tinyproxy/tinyproxy.log - sed -i -e"s,^#LogFile,LogFile," $PROXY_CONF -} - -setAccess() { - if [[ "$1" == *ANY* ]]; then - sed -i -e"s/^Allow /#Allow /" $PROXY_CONF - checkStatus $? "Allowing ANY - Could not edit $PROXY_CONF" \ - "Allowed ANY - Edited $PROXY_CONF successfully." - else - sed -i "s,^Allow 127.0.0.1,$1," $PROXY_CONF - checkStatus $? "Allowing IPs - Could not edit $PROXY_CONF" \ - "Allowed IPs - Edited $PROXY_CONF successfully." - fi -} - -startService() { - screenOut "Starting Tinyproxy service..." - /usr/sbin/tinyproxy - checkStatus $? "Could not start Tinyproxy service." \ - "Tinyproxy service started successfully." -} - -tailLog() { - screenOut "Tailing Tinyproxy log..." - tail -f $TAIL_LOG - checkStatus $? "Could not tail $TAIL_LOG" \ - "Stopped tailing $TAIL_LOG" -} - -# Start script -echo && screenOut "$PROG_NAME script started..." -# Stop Tinyproxy if running -stopService -# Parse ACL from args -export rawRules="$@" && parsedRules=$(parseAccessRules $rawRules) && unset rawRules -# Set ACL in Tinyproxy config -setAccess $parsedRules -# Enable log to file -#enableLogFile -# Start Tinyproxy -startService -# Tail Tinyproxy log -#tailLog -# End -screenOut "$PROG_NAME script ended." && echo -exit 0 diff --git a/tinyproxy/setport.sh b/tinyproxy/setport.sh index 4df1c8b37..1ef53aad6 100755 --- a/tinyproxy/setport.sh +++ b/tinyproxy/setport.sh @@ -13,10 +13,11 @@ fi if [ $1 \< 1024 ]; then - echo "$1 is lower than 1024. Ports below 1024 are not permitted."; + 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," $PROXY_CONF exit 0