Added existing project files

master
B.J. Dweck 1 year ago
parent 3d02504d7f
commit ff20e94032

@ -0,0 +1,20 @@
FROM alpine
ARG SVC_LISTEN_PORT
ARG SVC_TARGET_HOST
ARG SVC_TARGET_PORT
WORKDIR /etc/tor
RUN apk add --no-cache curl tor && \
echo -e "HiddenServiceDir /var/lib/tor/svc/\nHiddenServicePort $SVC_LISTEN_PORT $SVC_TARGET_HOST:$SVC_TARGET_PORT" > ./torrc
HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \
CMD curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations
COPY tor.sh /usr/local/bin/
COPY svc-hostname /usr/local/bin/
#USER tor
CMD [ "tor.sh", "$SVC_TARGET_HOST" ]

@ -0,0 +1,26 @@
Tor Proxy
===========================
This is a Tor Proxy Docker container for "torifying" other Docker-based services in a Docker Compose project. It creates a Tor Hidden Service with an onion hostname that persists as long as it's underlying storage volume. The Tor Hidden Service listens on the specified port and proxies traffice to the specified target host:port.
### Example Usage
`docker-compose.yml`:
```
...
mysvc_tor_proxy:
build:
context: ./tor
args:
- SVC_LISTEN_PORT=80
- SVC_TARGET_HOST=mysvc
- SVC_TARGET_PORT=8080
volumes:
- mysvc_config:/var/lib/tor
depends_on:
- mysvc
restart: unless-stopped
...
```

@ -0,0 +1,8 @@
#!/bin/sh
while ! curl -s -N --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations
do
sleep 0.5
done
echo $(cat /var/lib/tor/svc/hostname)

@ -0,0 +1,10 @@
#!/bin/sh
HOSTNAME=$1
IP_ADDR=$(nslookup $HOSTNAME | awk '/^Address: / { print $2 }' | tail -n1 | sed -e 's/[[:space:]]//g')
sed -i "s/$HOSTNAME/$IP_ADDR/g" /etc/tor/torrc
echo "*** Service Hostname: $(/usr/local/bin/svc-hostname)" &
tor
Loading…
Cancel
Save