Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
push:
branches:
- main
- alpha
- beta

jobs:
build:
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ RUN apk add --no-cache \
tinyproxy

COPY tinyproxy_configure.sh /scripts/tinyproxy_configure.sh
COPY keepalive.sh /scripts/keepalive.sh
COPY tp_run /scripts/tp_run
RUN chmod 755 /scripts/tinyproxy_configure.sh /scripts/tp_run
RUN chmod 755 /scripts/tinyproxy_configure.sh /scripts/tp_run /scripts/keepalive.sh

# The conneciton to PIA appears to timeout.
# The below environment variable is the frequency in seconds to curl a PIA endpoint to keep the connection alive.
# 300 == 5 minutes. See 'keepalive.sh' for more information.
ENV KEEPALIVE_INTERVAL=300

# The text that follows 'TINYPROXY_' needs to match the name of the configuration item found within the tinyproxy.conf file
# For configuration items that can be repeated (e.g. 'Allow'), the value should be a comma-separated list to be expanded by tinyproxy_configure.sh
ENV TINYPROXY_User=nobody
ENV TINYPROXY_Group=nobody
ENV TINYPROXY_Port=${TINYPROXY_PORT}
# Skipping 'TINYPROXY_Listen' -- 'Listen' is configured automatically by tinyproxy_configure.sh since the value isn't known until runtime
# Skipping 'TINYPROXY_Listen' -- 'Listen' behavior is to listen on all interfaces
# Skipping 'TINYPROXY_Bind' -- 'Bind' is configured automatically by tinyproxy_configure.sh since the value isn't known until runtime
ENV TINYPROXY_Timeout=600
ENV TINYPROXY_Timeout=180
ENV TINYPROXY_DefaultErrorFile='"/usr/share/tinyproxy/default.html"'
ENV TINYPROXY_StatFile='"/usr/share/tinyproxy/stats.html"'
ENV TINYPROXY_XTinyproxy=No
Expand Down
7 changes: 7 additions & 0 deletions keepalive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

while [ $KEEPALIVE_INTERVAL -gt 0 ]; do
sleep $KEEPALIVE_INTERVAL
curl -sS 'https://www.privateinternetaccess.com/site-api/get-location-info' \
-H 'Accept: application/json' > /tmp/keepalive.json
done
10 changes: 8 additions & 2 deletions tp_run
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
$(/scripts/run) &

# Use the healthcheck script from the base image to ensure the 'wg0' interface will have an IP for tinyproxy to 'Bind' to.
/scripts/healthcheck.sh > /dev/null 2>&1
/scripts/healthcheck.sh
health=$?
while [ $health -ne 0 ]
do
echo "Waiting on VPN connectivity..."
sleep 1
/scripts/healthcheck.sh > /dev/null 2>&1
/scripts/healthcheck.sh
health=$?
done

#### Currently just a guess, but the VPN connection seems to eventually timeout from inactivity.
# This script will curl a PIA endpoint every KEEPALIVE_INTERVAL seconds. 0 (zero) will cause it to exit immediately.
# The script outputs the curl response to /tmp/keepalive.json
echo "Starting keepalive script..."
/scripts/keepalive.sh &

####
## Configure and start Tinyproxy
# Writes the Tinyproxy config to '/etc/tinyproxy/tinyproxy.conf'
Expand Down