Added BasicAuth to tinyproxy, updated docs and dockerfiles

This commit is contained in:
Patrick Kishino
2020-05-29 15:03:10 +09:00
parent 86951a97e5
commit 8fc5503879
9 changed files with 36 additions and 10 deletions

View File

@@ -85,4 +85,6 @@
#TRANSMISSION_WATCH_DIR_FORCE_GENERIC=false #TRANSMISSION_WATCH_DIR_FORCE_GENERIC=false
#WEBPROXY_ENABLED=false #WEBPROXY_ENABLED=false
#WEBPROXY_PORT=8888 #WEBPROXY_PORT=8888
#WEBPROXY_USERNAME=
#WEBPROXY_PASSWORD=
#DOCKER_LOG=false #DOCKER_LOG=false

View File

@@ -1,4 +1,4 @@
FROM ubuntu:18.04 FROM ubuntu:19.10
VOLUME /data VOLUME /data
VOLUME /config VOLUME /config
@@ -12,12 +12,12 @@ ENV DEBIAN_FRONTEND=noninteractive
# Update, upgrade and install core software # Update, upgrade and install core software
RUN apt update \ RUN apt update \
&& apt -y upgrade \ && apt -y install apt-utils software-properties-common wget git curl jq \
&& apt -y install software-properties-common wget git curl jq \
&& add-apt-repository ppa:transmissionbt/ppa \ && add-apt-repository ppa:transmissionbt/ppa \
&& apt update \ && apt update \
&& apt install -y sudo transmission-cli transmission-common transmission-daemon curl rar unrar zip unzip ufw iputils-ping openvpn bc tzdata \ && apt install -y sudo transmission-cli transmission-common transmission-daemon curl rar unrar zip unzip ufw iputils-ping openvpn bc tzdata bash \
python2.7 python2.7-pysqlite2 && ln -sf /usr/bin/python2.7 /usr/bin/python2 \ python2.7 python2.7-pysqlite2 && ln -sf /usr/bin/python2.7 /usr/bin/python2 \
&& apt -y upgrade \
&& wget https://github.com/Secretmapper/combustion/archive/release.zip \ && wget https://github.com/Secretmapper/combustion/archive/release.zip \
&& unzip release.zip -d /opt/transmission-ui/ \ && unzip release.zip -d /opt/transmission-ui/ \
&& rm release.zip \ && rm release.zip \
@@ -28,7 +28,7 @@ RUN apt update \
&& ln -s /usr/share/transmission/web/javascript /opt/transmission-ui/transmission-web-control \ && ln -s /usr/share/transmission/web/javascript /opt/transmission-ui/transmission-web-control \
&& ln -s /usr/share/transmission/web/index.html /opt/transmission-ui/transmission-web-control/index.original.html \ && ln -s /usr/share/transmission/web/index.html /opt/transmission-ui/transmission-web-control/index.original.html \
&& git clone git://github.com/endor/kettu.git /opt/transmission-ui/kettu \ && git clone git://github.com/endor/kettu.git /opt/transmission-ui/kettu \
&& apt install -y tinyproxy telnet \ && apt install -y tinyproxy telnet vim \
&& wget https://github.com/Yelp/dumb-init/releases/download/v${DUMBINIT_VERSION}/dumb-init_${DUMBINIT_VERSION}_amd64.deb \ && wget https://github.com/Yelp/dumb-init/releases/download/v${DUMBINIT_VERSION}/dumb-init_${DUMBINIT_VERSION}_amd64.deb \
&& dpkg -i dumb-init_${DUMBINIT_VERSION}_amd64.deb \ && dpkg -i dumb-init_${DUMBINIT_VERSION}_amd64.deb \
&& rm -rf dumb-init_${DUMBINIT_VERSION}_amd64.deb \ && rm -rf dumb-init_${DUMBINIT_VERSION}_amd64.deb \
@@ -133,6 +133,8 @@ ENV OPENVPN_USERNAME=**None** \
DROP_DEFAULT_ROUTE= \ DROP_DEFAULT_ROUTE= \
WEBPROXY_ENABLED=false \ WEBPROXY_ENABLED=false \
WEBPROXY_PORT=8888 \ WEBPROXY_PORT=8888 \
WEBPROXY_USERNAME= \
WEBPROXY_PASSWORD= \
HEALTH_CHECK_HOST=google.com \ HEALTH_CHECK_HOST=google.com \
DOCKER_LOG=false DOCKER_LOG=false

View File

@@ -6,7 +6,7 @@ VOLUME /config
ARG DOCKERIZE_ARCH=amd64 ARG DOCKERIZE_ARCH=amd64
ENV DOCKERIZE_VERSION=v0.6.0 ENV DOCKERIZE_VERSION=v0.6.0
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache add bash dumb-init ip6tables ufw@testing openvpn shadow transmission-daemon transmission-cli curl jq tzdata \ && apk --no-cache add bash dumb-init ip6tables ufw@testing openvpn shadow transmission-daemon transmission-cli curl jq tzdata tinyproxy \
&& echo "Install dockerize $DOCKERIZE_VERSION ($DOCKERIZE_ARCH)" \ && echo "Install dockerize $DOCKERIZE_VERSION ($DOCKERIZE_ARCH)" \
&& wget -qO- https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-$DOCKERIZE_ARCH-$DOCKERIZE_VERSION.tar.gz | tar xz -C /usr/bin \ && wget -qO- https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-$DOCKERIZE_ARCH-$DOCKERIZE_VERSION.tar.gz | tar xz -C /usr/bin \
&& mkdir -p /opt/transmission-ui \ && mkdir -p /opt/transmission-ui \
@@ -27,8 +27,10 @@ RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/ap
&& useradd -u 911 -U -d /config -s /bin/false abc \ && useradd -u 911 -U -d /config -s /bin/false abc \
&& usermod -G users abc && usermod -G users abc
# Add configuration and scripts
ADD openvpn/ /etc/openvpn/ ADD openvpn/ /etc/openvpn/
ADD transmission/ /etc/transmission/ ADD transmission/ /etc/transmission/
ADD tinyproxy /opt/tinyproxy/
ADD scripts /etc/scripts/ ADD scripts /etc/scripts/
ENV OPENVPN_USERNAME=**None** \ ENV OPENVPN_USERNAME=**None** \
@@ -121,6 +123,8 @@ ENV OPENVPN_USERNAME=**None** \
DROP_DEFAULT_ROUTE= \ DROP_DEFAULT_ROUTE= \
WEBPROXY_ENABLED=false \ WEBPROXY_ENABLED=false \
WEBPROXY_PORT=8888 \ WEBPROXY_PORT=8888 \
WEBPROXY_USERNAME= \
WEBPROXY_PASSWORD= \
DOCKER_LOG=false \ DOCKER_LOG=false \
HEALTH_CHECK_HOST=google.com HEALTH_CHECK_HOST=google.com

View File

@@ -9,9 +9,9 @@ VOLUME /config
# Update packages and install software # Update packages and install software
RUN apt-get update \ RUN apt-get update \
&& apt-get -y install apt-utils \ && apt-get -y install apt-utils transmission-cli transmission-common transmission-daemon \
&& apt-get -y install transmission-cli transmission-common transmission-daemon \ && apt-get install -y dumb-init unzip openvpn curl ufw git tinyproxy jq bash \
&& apt-get install -y dumb-init unzip openvpn curl ufw git tinyproxy jq \ && apt-get -y upgrade \
&& curl -L -o /tmp/release.zip https://github.com/Secretmapper/combustion/archive/release.zip \ && curl -L -o /tmp/release.zip https://github.com/Secretmapper/combustion/archive/release.zip \
&& unzip /tmp/release.zip -d /opt/transmission-ui/ \ && unzip /tmp/release.zip -d /opt/transmission-ui/ \
&& rm /tmp/release.zip \ && rm /tmp/release.zip \
@@ -127,6 +127,8 @@ ENV OPENVPN_USERNAME=**None** \
DROP_DEFAULT_ROUTE= \ DROP_DEFAULT_ROUTE= \
WEBPROXY_ENABLED=false \ WEBPROXY_ENABLED=false \
WEBPROXY_PORT=8888 \ WEBPROXY_PORT=8888 \
WEBPROXY_USERNAME= \
WEBPROXY_PASSWORD= \
DOCKER_LOG=false \ DOCKER_LOG=false \
HEALTH_CHECK_HOST=google.com HEALTH_CHECK_HOST=google.com

View File

@@ -78,11 +78,14 @@ This is useful if you are using a private tracker that needs to see you login fr
The default listening port is 8888. Note that only ports above 1024 can be specified as all ports below 1024 are privileged 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. and would otherwise require root permissions to run.
Remember to add a port binding for your selected (or default) port when starting the container. Remember to add a port binding for your selected (or default) port when starting the container.
If you set Username and Password it will enable BasicAuth for the proxy
| Variable | Function | Example | | Variable | Function | Example |
| ------------------ | ----------------------- | ----------------------- | | ------------------ | ----------------------- | ----------------------- |
| `WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true` | | `WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true` |
| `WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` | | `WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` |
| `WEBPROXY_USERNAME`| Sets the BasicAuth username | `WEBPROXY_USERNAME=test` |
| `WEBPROXY_PASSWORD`| Sets the BasicAuth password | `WEBPROXY_PASSWORD=password` |
### User configuration options ### User configuration options

View File

@@ -230,6 +230,8 @@ Remember to add a port binding for your selected (or default) port when starting
| ------------------ | ----------------------- | ----------------------- | | ------------------ | ----------------------- | ----------------------- |
| `WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true` | | `WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true` |
| `WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` | | `WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` |
| `WEBPROXY_USERNAME`| Sets the BasicAuth username | `WEBPROXY_USERNAME=test` |
| `WEBPROXY_PASSWORD`| Sets the BasicAuth password | `WEBPROXY_PASSWORD=password` |
### User configuration options ### User configuration options

View File

@@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
/etc/transmission/start.sh "$@" /etc/transmission/start.sh "$@"
[[ ! -f /opt/tinyproxy/start.sh ]] || /opt/tinyproxy/start.sh [[ ! -f /opt/tinyproxy/start.sh ]] || /opt/tinyproxy/start.sh

View File

@@ -38,6 +38,12 @@ set_port()
sed -i -e"s,^Port .*,Port $1," $2 sed -i -e"s,^Port .*,Port $1," $2
} }
set_authentication()
{
echo "Setting tinyproxy basic auth";
echo "BasicAuth $1 $2" >> $3
}
if [[ "${WEBPROXY_ENABLED}" = "true" ]]; then if [[ "${WEBPROXY_ENABLED}" = "true" ]]; then
echo "STARTING TINYPROXY" echo "STARTING TINYPROXY"
@@ -47,6 +53,10 @@ if [[ "${WEBPROXY_ENABLED}" = "true" ]]; then
set_port ${WEBPROXY_PORT} ${PROXY_CONF} set_port ${WEBPROXY_PORT} ${PROXY_CONF}
if [[ ! -z "${WEBPROXY_USERNAME}" ]] && [[ ! -z "${WEBPROXY_PASSWORD}" ]]; then
set_authentication ${WEBPROXY_USERNAME} ${WEBPROXY_PASSWORD} ${PROXY_CONF}
fi
# Allow all clients # Allow all clients
sed -i -e"s/^Allow /#Allow /" ${PROXY_CONF} sed -i -e"s/^Allow /#Allow /" ${PROXY_CONF}

View File

@@ -85,6 +85,8 @@ export PGID={{ .Env.PGID }}
# Need to pass through our tinyproxy settings # Need to pass through our tinyproxy settings
export WEBPROXY_ENABLED={{ .Env.WEBPROXY_ENABLED }} export WEBPROXY_ENABLED={{ .Env.WEBPROXY_ENABLED }}
export WEBPROXY_PORT={{ .Env.WEBPROXY_PORT }} export WEBPROXY_PORT={{ .Env.WEBPROXY_PORT }}
export WEBPROXY_USERNAME={{ .Env.WEBPROXY_USERNAME }}
export WEBPROXY_PASSWORD={{ .Env.WEBPROXY_PASSWORD }}
# Support custom web frontend # Support custom web frontend
{{ if .Env.TRANSMISSION_WEB_HOME }} export TRANSMISSION_WEB_HOME={{ .Env.TRANSMISSION_WEB_HOME }} {{end}} {{ if .Env.TRANSMISSION_WEB_HOME }} export TRANSMISSION_WEB_HOME={{ .Env.TRANSMISSION_WEB_HOME }} {{end}}