mirror of
https://github.com/fphammerle/docker-tor-proxy.git
synced 2025-10-27 02:43:35 +01:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71cd9e4843 | |||
| 677e9db8e2 | |||
| 8ae9e9e5b7 | |||
| 1951c1f3a9 | |||
| edac4ed3da | |||
| 5cc893c3c3 | |||
| 4e2e1bbf4f | |||
| 40b88ec7d5 | |||
| 67c5c44495 | |||
| ba4cafac27 | |||
| fea43b11d8 | |||
| 4f6950af1d | |||
| 7cbef67a3f | |||
| dfe104eb09 | |||
| 6a9e7a1f42 | |||
| 8d1a635ddc | |||
| d573073454 | |||
| ccb9eb52a1 | |||
| b85bfc4d53 | |||
| 9d8903fbee | |||
| 8cc0734979 | |||
| 2778ba83d0 | |||
| d12b5387bd | |||
| 97aca0c2c6 | |||
| a28bf73885 | |||
| 1440258718 | |||
| 7fb3c50db6 | |||
| c44166f264 | |||
| b0d0e8da22 | |||
| ef97bc410f | |||
| a4f7946ced | |||
| dcb78b66c5 | |||
| 7bce89fedf |
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
|
||||
updates:
|
||||
- package-ecosystem: docker
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: friday
|
||||
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
+49
-11
@@ -6,30 +6,68 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.0.0] - 2020-03-24
|
||||
## [4.1.0] - 2021-03-03
|
||||
### Added
|
||||
- enabled transparent proxy, listening on port `9040` (requires netfilter rules)
|
||||
- image labels:
|
||||
- `org.opencontainers.image.revision` (git commit hash via build arg)
|
||||
- `org.opencontainers.image.source` (repo url)
|
||||
- `org.opencontainers.image.title`
|
||||
|
||||
## [4.0.0] - 2021-01-01
|
||||
### Changed
|
||||
- Changed DNS port from 53 to 9053
|
||||
- healthcheck: replace periodic http requests with probing
|
||||
[network-liveness](https://gitweb.torproject.org/torspec.git/tree/control-spec.txt)
|
||||
to improve privacy (keeping dns requests for faster updates)
|
||||
- changed log level of `control` domain to `warn`
|
||||
(to avoid log spam by healthcheck connecting to control listener)
|
||||
- added message domains to log messages
|
||||
|
||||
### Removed
|
||||
- `curl`
|
||||
- `bind-tools` package including `dig`
|
||||
|
||||
## [3.0.0] - 2020-10-03
|
||||
### Added
|
||||
- create mount point at `/var/lib/tor`
|
||||
to be able to make container's root filesystem read-only
|
||||
|
||||
### Changed
|
||||
- moved tor's data directory from `/home/onion/.tor` to `/var/lib/tor`
|
||||
- run `tor` as user `tor` (uid=100) instead of `onion` (uid=101)
|
||||
- docker-compose & ansible-playbook: read-only root filesystem
|
||||
|
||||
### Fixed
|
||||
- Run as unprivileged user
|
||||
- ansible-playbook: drop capabilities
|
||||
|
||||
## [2.1.0] - 2020-09-27
|
||||
### Added
|
||||
- enable [tor control](https://gitweb.torproject.org/torspec.git/tree/control-spec.txt)
|
||||
listener on port `9051`
|
||||
(listening on loopback device only)
|
||||
|
||||
## [2.0.0] - 2020-03-24
|
||||
### Changed
|
||||
- changed DNS port from 53 to 9053
|
||||
- run as unprivileged user
|
||||
|
||||
## [1.1.1] - 2020-03-21
|
||||
### Fixed
|
||||
- Fix invalid torrc path
|
||||
- fix invalid torrc path
|
||||
|
||||
## [1.1.0] - 2020-03-21
|
||||
### Added
|
||||
- Change `SocksTimeout` option by setting `$SOCKS_TIMEOUT_SECONDS`
|
||||
|
||||
### Fixed
|
||||
- upgrade default tor version: 0.4.1.6 -> 0.4.1.9
|
||||
(non-breaking, fixes only, https://gitweb.torproject.org/tor.git/plain/ChangeLog)
|
||||
- change `SocksTimeout` option by setting `$SOCKS_TIMEOUT_SECONDS`
|
||||
|
||||
## [1.0.0] - 2019-10-12
|
||||
### Added
|
||||
- Tor Socks5 & DNS proxy
|
||||
- tor socks5 & DNS proxy
|
||||
|
||||
[Unreleased]: https://github.com/fphammerle/docker-tor-proxy/compare/v2.0.0...HEAD
|
||||
[Unreleased]: https://github.com/fphammerle/docker-tor-proxy/compare/v4.1.0...HEAD
|
||||
[4.1.0]: https://github.com/fphammerle/docker-tor-proxy/compare/v4.0.0...v4.1.0
|
||||
[4.0.0]: https://github.com/fphammerle/docker-tor-proxy/compare/v3.0.0...v4.0.0
|
||||
[3.0.0]: https://github.com/fphammerle/docker-tor-proxy/compare/v2.1.0...v3.0.0
|
||||
[2.1.0]: https://github.com/fphammerle/docker-tor-proxy/compare/v2.0.0...v2.1.0
|
||||
[2.0.0]: https://github.com/fphammerle/docker-tor-proxy/compare/v1.1.1...v2.0.0
|
||||
[1.1.1]: https://github.com/fphammerle/docker-tor-proxy/compare/v1.1.0...v1.1.1
|
||||
[1.1.0]: https://github.com/fphammerle/docker-tor-proxy/compare/1.0.0...v1.1.0
|
||||
|
||||
+22
-18
@@ -1,31 +1,35 @@
|
||||
FROM alpine:3.11
|
||||
FROM docker.io/alpine:3.13.2
|
||||
|
||||
ARG CURL_PACKAGE_VERSION=7.67.0-r0
|
||||
ARG BIND_TOOLS_PACKAGE_VERSION=9.14.8-r5
|
||||
ARG TOR_PACKAGE_VERSION=0.4.1.9-r0
|
||||
RUN adduser -S onion \
|
||||
&& apk add --no-cache \
|
||||
curl=$CURL_PACKAGE_VERSION \
|
||||
bind-tools=$BIND_TOOLS_PACKAGE_VERSION `# dig` \
|
||||
tor=$TOR_PACKAGE_VERSION
|
||||
ARG TOR_PACKAGE_VERSION=0.4.4.7-r1
|
||||
RUN apk add --no-cache tor=$TOR_PACKAGE_VERSION
|
||||
VOLUME /var/lib/tor
|
||||
|
||||
# RUN apk add --no-cache \
|
||||
# less \
|
||||
# man \
|
||||
# tor-doc=$TOR_PACKAGE_VERSION
|
||||
# ENV PAGER=less
|
||||
#RUN apk add --no-cache \
|
||||
# less \
|
||||
# man-db \
|
||||
# tor-doc=$TOR_PACKAGE_VERSION
|
||||
#ENV PAGER=less
|
||||
|
||||
EXPOSE 9050/tcp
|
||||
EXPOSE 9053/udp
|
||||
COPY torrc.template entrypoint.sh /
|
||||
RUN chmod -c a+rX /torrc.template /entrypoint.sh
|
||||
ENV SOCKS_TIMEOUT_SECONDS=
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
RUN chmod -c a+rX /torrc.template /entrypoint.sh
|
||||
|
||||
USER onion
|
||||
USER tor
|
||||
CMD ["tor", "-f", "/tmp/torrc"]
|
||||
|
||||
# keeping dns requests as network-liveness is too optimistic
|
||||
# https://gitweb.torproject.org/torspec.git/tree/control-spec.txt
|
||||
HEALTHCHECK CMD \
|
||||
curl --silent --socks5 localhost:9050 https://google.com > /dev/null \
|
||||
&& [ ! -z "$(dig -p 9053 +notcp +short one.one.one.one @localhost)" ] \
|
||||
printf "AUTHENTICATE\nGETINFO network-liveness\nQUIT\n" | nc localhost 9051 \
|
||||
| grep -q network-liveness=up \
|
||||
&& nslookup -port=9053 google.com localhost | grep -v NXDOMAIN | grep -q google \
|
||||
|| exit 1
|
||||
|
||||
# https://github.com/opencontainers/image-spec/blob/v1.0.1/annotations.md
|
||||
ARG REVISION=
|
||||
LABEL org.opencontainers.image.title="tor socks, dns & transparent proxy" \
|
||||
org.opencontainers.image.source="https://github.com/fphammerle/docker-tor-proxy" \
|
||||
org.opencontainers.image.revision="$REVISION"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
IMAGE_NAME := docker.io/fphammerle/tor-proxy
|
||||
PROJECT_VERSION = $(shell git describe --match=v* --abbrev=0 --dirty | sed -e 's/^v//')
|
||||
TOR_PACKAGE_VERSION = $(shell grep -Po 'TOR_PACKAGE_VERSION=\K.+' Dockerfile | tr -d -)
|
||||
ARCH = $(shell arch)
|
||||
# architecture[arm_variant]
|
||||
# https://github.com/opencontainers/image-spec/blob/v1.0.1/image-index.md#image-index-property-descriptions
|
||||
IMAGE_TAG_ARCH_aarch64 = arm64
|
||||
IMAGE_TAG_ARCH_armv6l = armv6
|
||||
IMAGE_TAG_ARCH_armv7l = armv7
|
||||
IMAGE_TAG_ARCH_x86_64 = amd64
|
||||
IMAGE_TAG_ARCH = ${IMAGE_TAG_ARCH_${ARCH}}
|
||||
IMAGE_TAG = ${PROJECT_VERSION}-tor${TOR_PACKAGE_VERSION}-${IMAGE_TAG_ARCH}
|
||||
BUILD_PARAMS = --tag="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
--build-arg=REVISION="$(shell git rev-parse HEAD)"
|
||||
|
||||
.PHONY: worktree-clean docker-build podman-build docker-push
|
||||
|
||||
worktree-clean:
|
||||
git diff --exit-code
|
||||
git diff --staged --exit-code
|
||||
|
||||
docker-build: worktree-clean
|
||||
sudo docker build ${BUILD_PARAMS} .
|
||||
|
||||
podman-build: worktree-clean
|
||||
# --format=oci (default) not fully supported by hub.docker.com
|
||||
# https://github.com/docker/hub-feedback/issues/1871#issuecomment-748924149
|
||||
podman build --format=docker ${BUILD_PARAMS} .
|
||||
|
||||
docker-push: docker-build
|
||||
sudo docker push "${IMAGE_NAME}:${IMAGE_TAG}"
|
||||
@echo git tag --sign --message '$(shell sudo docker image inspect --format '{{join .RepoDigests "\n"}}' "${IMAGE_NAME}:${IMAGE_TAG}")' docker/${IMAGE_TAG} $(shell git rev-parse HEAD)
|
||||
@@ -5,18 +5,19 @@ docker hub: https://hub.docker.com/r/fphammerle/tor-proxy
|
||||
signed tags: https://github.com/fphammerle/docker-tor-proxy/tags
|
||||
|
||||
```sh
|
||||
$ docker run --rm --name tor-proxy \
|
||||
$ sudo docker run --rm --name tor_proxy \
|
||||
-p 127.0.0.1:9050:9050/tcp \
|
||||
-p 127.0.0.1:53:53/udp \
|
||||
-p 127.0.0.1:53:9053/udp \
|
||||
fphammerle/tor-proxy
|
||||
```
|
||||
|
||||
or after cloning the repository 🐙
|
||||
```sh
|
||||
$ docker-compose up
|
||||
$ sudo docker-compose up
|
||||
```
|
||||
|
||||
test proxies:
|
||||
### test proxies
|
||||
|
||||
```sh
|
||||
$ curl --proxy socks5h://localhost:9050 ipinfo.io
|
||||
$ torsocks wget -O - ipinfo.io
|
||||
@@ -27,12 +28,30 @@ $ ssh -o 'ProxyCommand nc -x localhost:9050 -v %h %p' abcdefghi.onion
|
||||
$ chromium-browser --proxy-server=socks5://localhost:9050 ipinfo.io
|
||||
```
|
||||
|
||||
isolate:
|
||||
### read-only root filesystem
|
||||
|
||||
optionally add
|
||||
```sh
|
||||
iptables -A OUTPUT ! -o lo -j REJECT --reject-with icmp-admin-prohibited
|
||||
$ sudo docker run --read-only -v tor_proxy_data:/var/lib/tor --tmpfs /tmp:rw,size=4k` …
|
||||
```
|
||||
to make the container's root filesystem read-only
|
||||
|
||||
### isolate
|
||||
|
||||
```sh
|
||||
sudo iptables -A OUTPUT ! -o lo -j REJECT --reject-with icmp-admin-prohibited
|
||||
```
|
||||
|
||||
change `SocksTimeout` option:
|
||||
### change `SocksTimeout` option
|
||||
|
||||
```sh
|
||||
$ docker run -e SOCKS_TIMEOUT_SECONDS=60 …
|
||||
$ sudo docker run -e SOCKS_TIMEOUT_SECONDS=60 …
|
||||
```
|
||||
|
||||
### show circuits
|
||||
|
||||
```sh
|
||||
$ sudo docker exec tor_proxy \
|
||||
sh -c 'printf "AUTHENTICATE\nGETINFO circuit-status\nQUIT\n" | nc localhost 9051'
|
||||
```
|
||||
relay search: https://metrics.torproject.org/rs.html
|
||||
|
||||
+18
-4
@@ -7,16 +7,30 @@
|
||||
com.docker.network.bridge.name: tor
|
||||
- docker_container:
|
||||
name: tor_proxy
|
||||
# 1.0.0-tor0.4.1.6-amd64
|
||||
image: fphammerle/tor-proxy@sha256:ad55d07b1b21c35fa044dc3e1ea6c7d8494f39eb89491ddad35c245340f7cd4b
|
||||
# object 9d8903fbee049c379537c5e291cfa88f57b049f2
|
||||
# tag docker/3.0.0-tor0.4.3.5-amd64
|
||||
image: docker.io/fphammerle/tor-proxy@sha256:501c5b5432156f25ecfce9e48ebfe0827f7702a1d32206af79f256cc94487a0f
|
||||
mounts:
|
||||
- type: volume
|
||||
source: tor_proxy_data
|
||||
target: /var/lib/tor
|
||||
read_only: no
|
||||
- type: tmpfs
|
||||
target: /tmp # torrc
|
||||
# nosuid,nodev,noexec added by default
|
||||
tmpfs_mode: '1777'
|
||||
tmpfs_size: 4k
|
||||
read_only: yes
|
||||
networks:
|
||||
- name: tor_proxy_network
|
||||
purge_networks: yes
|
||||
ports:
|
||||
- '127.0.0.1:9050:9050/tcp'
|
||||
- '127.0.0.1:53:53/udp'
|
||||
restart_policy: unless-stopped
|
||||
- '127.0.0.1:53:9053/udp'
|
||||
cap_drop: [ALL]
|
||||
security_opts: [no-new-privileges]
|
||||
memory: 128M
|
||||
restart_policy: unless-stopped
|
||||
- iptables:
|
||||
action: append
|
||||
table: filter
|
||||
|
||||
+22
-6
@@ -1,18 +1,34 @@
|
||||
version: '2.2'
|
||||
version: '2.3'
|
||||
|
||||
volumes:
|
||||
data:
|
||||
|
||||
services:
|
||||
tor_proxy:
|
||||
build: .
|
||||
image: fphammerle/tor-proxy
|
||||
environment:
|
||||
SOCKS_TIMEOUT_SECONDS: 30
|
||||
volumes:
|
||||
- type: volume
|
||||
source: data
|
||||
target: /var/lib/tor
|
||||
read_only: no
|
||||
- type: tmpfs
|
||||
target: /tmp # torrc
|
||||
tmpfs:
|
||||
# nosuid,nodev,noexec added by default
|
||||
mode: '1777'
|
||||
size: 4k
|
||||
read_only: yes
|
||||
ports:
|
||||
- '127.0.0.1:9050:9050/tcp'
|
||||
- '127.0.0.1:53:9053/udp'
|
||||
environment:
|
||||
SOCKS_TIMEOUT_SECONDS: 240
|
||||
security_opt: ['no-new-privileges']
|
||||
restart: unless-stopped
|
||||
cap_drop: [ALL]
|
||||
#cap_add: [SYS_PTRACE]
|
||||
security_opt: [no-new-privileges]
|
||||
cpus: 0.5
|
||||
mem_limit: 128m
|
||||
#cap_add: [SYS_PTRACE]
|
||||
restart: unless-stopped
|
||||
|
||||
# https://docs.docker.com/compose/compose-file/compose-file-v2/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
https://gitweb.torproject.org/tor.git/plain/ChangeLog
|
||||
+23
-2
@@ -1,9 +1,30 @@
|
||||
Log notice stdout
|
||||
# https://www.torproject.org/docs/tor-manual.html.en
|
||||
|
||||
# hide healthchecks:
|
||||
# > [notice] {CONTROL} New control connection opened from 127.0.0.1.
|
||||
Log [~control]notice warn stdout
|
||||
LogMessageDomains 1
|
||||
|
||||
# default: ~/.tor
|
||||
DataDirectory /var/lib/tor
|
||||
|
||||
# https://gitweb.torproject.org/torspec.git/tree/control-spec.txt
|
||||
ControlPort localhost:9051
|
||||
|
||||
SocksPort 0.0.0.0:9050
|
||||
DNSPort 0.0.0.0:9053
|
||||
|
||||
SocksPort 0.0.0.0:9050
|
||||
SocksTimeout {socks_timeout_seconds}
|
||||
|
||||
# requires netfilter rules
|
||||
# socks5 with auth-based circuit isolation (tor browser, torsocks --isolate) should be preferred
|
||||
# cave: IsolateDestAddr & IsolateDestPort are not enabled
|
||||
# https://gitlab.torproject.org/legacy/trac/-/wikis/doc/TransparentProxy
|
||||
# https://github.com/epidemics-scepticism/writing/blob/b6733379d653b30771d578ace04c262600345122/misconception.md#transparent-proxying-lacks-context
|
||||
# https://lists.torproject.org/pipermail/tor-talk/2014-March/032507.html
|
||||
# https://gitweb.torproject.org/tor.git/tree/src/or/connection_edge.c?id=6285d9bdcf7f210c56abd25f75133e30d05a7473#n1423
|
||||
# https://github.com/mitmproxy/mitmproxy/blob/v6.0.2/mitmproxy/platform/linux.py#L27
|
||||
TransPort 0.0.0.0:9040 IsolateClientAddr IsolateClientProtocol
|
||||
|
||||
# try to
|
||||
HardwareAccel 1
|
||||
|
||||
Reference in New Issue
Block a user