Syntax highlighting of itnotes/tor
= Tor = <<TableOfContents()>> == Refs == [[https://iplocation.io/]] [[https://iplocation.com/]] [[http://jsonip.com/]] == HTTP proxy via torproxy == [[https://hub.docker.com/r/dperson/torproxy]] [[https://sccmrookie.blogspot.com/2016/03/tor-country-codes-list.html]] Create config file ''torrc'' with list of "exit nodes" {{{ ExitNodes {ru},{by},{kz},{ua} StrictNodes 1 }}} Run torproxy container {{{#!highlight bash docker run --rm \ -p 8118:8118 \ -v /path/to/torrc:/etc/tor/torrc:ro \ --name torh \ dperson/torproxy # --- or without config on localhost docker run --rm \ -p 127.0.0.1:8118:8118 \ --name torh \ dperson/torproxy }}} Check tor configuration {{{#!highlight bash # --- var 1 curl -Lx http://localhost:8118 http://jsonip.com/ # --- var 2 docker run --rm \ -e http_proxy=http://torh:8118 \ -e https_proxy=http://torh:8118 \ --link torh \ alpine/httpie http://httpbin.org/get }}} Place IP address from response to https://iplocation.com/ Run torproxy in compose {{{#!highlight yaml torproxy: container_name: torproxy image: dperson/torproxy:latest volumes: - ./torrc:/etc/tor/torrc:ro expose: - 1881 someservice: # ... environment: http_proxy: "http://torproxy:8118" https_proxy: "http://torproxy:8118" }}} == Socks5 proxy == https://github.com/ogarcia/docker-tor torrc {{{ SOCKSPort 0.0.0.0:9050 DataDirectory /var/lib/tor }}} data dir {{{#!highlight bash mkdir data chown 100:100 data }}} Run container {{{#!highlight bash # export http_proxy=socks5://127.0.0.1:8080 https_proxy=socks5://127.0.0.1:8080 docker run --rm -d \ --name=tors \ -p 9050:9050 \ -v /path/to/torrc/dir:/etc/tor \ -v /path/to/data:/var/lib/tor \ connectical/tor # --- for devhost cd docker run --rm \ --name=tors \ -p 9050:9050 \ -v $(pwd)/tmp/tor/cfg:/etc/tor \ -v $(pwd)/tmp/tor/data:/var/lib/tor \ connectical/tor }}} Check configuration {{{#!highlight bash curl -x socks5://localhost:9050 https://jsonip.com/ # --- or docker run --rm \ -e http_proxy=socks5://tors:9050 \ -e https_proxy=socks5://tors:9050 \ --link tors \ alpine/httpie http://httpbin.org/get }}} == Running custom Tor == https://dev.to/nabarun/running-tor-proxy-with-docker-56n9 torrc {{{ SOCKSPort 0.0.0.0:9050 }}} Dockerfile {{{#!highlight Dockerfile # set alpine as the base image of the Dockerfile FROM alpine:latest # update the package repository and install Tor RUN apk update && apk add tor # Copy over the torrc created above and set the owner to `tor` COPY torrc /etc/tor/torrc RUN chown -R tor /etc/tor # Set `tor` as the default user during the container runtime USER tor # Set `tor` as the entrypoint for the image ENTRYPOINT ["tor"] # Set the default container command # This can be overridden later when running a container CMD ["-f", "/etc/tor/torrc"] }}} {{{#!highlight bash docker build -t tora . docker run --rm -d \ --name tora \ -p 9050:9050 \ tora curl https://check.torproject.org/api/ip curl --socks5 127.0.0.1:9050 https://check.torproject.org/api/ip }}} == Native TOR == Config {{{#!highlight bash sudo vim /etc/tor/torrc }}} Sevice {{{#!highlight bash sudo systemctl status tor }}} Logs {{{#!highlight bash sudo journalctl -b --no-pager -f /usr/bin/tor }}}
