Help us understand the problem. What is going on with this article?

[メモ] ラズパイ: Tor proxyで、.onionドメインにアクセス

More than 1 year has passed since last update.
  • *.onion にアクセスするメモ

概要

環境

  • Raspberry Pi 3B
  • Raspbian: 2018-11-13-raspbian-stretch.zip
  • パッケージ更新: 2018/3/27 (apt update && apt upgrade)

    • Chromiumが、72.0.になった

      pi@raspberrypi:~ $ chromium-browser --version
       --disable-quic --enable-tcp-fast-open --disable-gpu-compositing --ppapi-flash-path=/usr/lib/chromium-browser/libpepflashplayer.so --ppapi-flash-args=enable_stagevideo_auto=0 --ppapi-flash-version=
      Chromium 72.0.3626.121 Built on Raspbian , running on Raspbian 9.8
      pi@raspberrypi:~y $ 
      
  • Docker 導入しておく。
    curl -sSL https:/get.docker.com | sh && sudo usermod -aG docker $USER

手順

  1. Torコンテナの準備

    DOCKER_NAME=tor-socks-proxy
    
    # git クローン : ${DOCKER_CONTAINER_NAME} フォルダへ
    git clone https://github.com/PeterDaveHello/tor-socks-proxy ${DOCKER_NAME}
    cd ${DOCKER_NAME}
    
    # ビルド
    docker build . -t ${DOCKER_NAME}
    
  2. コンテナ起動
    -pオプションにて、ローカルのみか、誰でも接続できるか、指定できる

    起動
    # ローカルのみ接続許可
    docker run -d --name ${DOCKER_NAME} -p 127.0.0.1:9150:9150 ${DOCKER_NAME}
    
    # 誰でも接続できる
    # docker run -d --name ${DOCKER_NAME} -p 9150:9150 ${DOCKER_NAME}
    
    # 様子を見る
    docker logs ${DOCKER_NAME}
    
    # > ...
    # > Mar 28 01:34:19.000 [notice] Bootstrapped 100%: Done
    # こんな感じのが出てたら、起動OK
    
  3. 接続テスト

    1. curl -x socks5h://localhost:9150 https://ipinfo.io/ip

      pi@raspberrypi:~ $ curl -x socks5h://localhost:9150 https://ipinfo.io/ip
      185.220.101.27
      pi@raspberrypi:~ $ 
      
    2. chromiumにて
      https://3g2upl4pq6kufc4m.onion/ は DuckDuckGoへ行きます。

      chromium-browser --proxy-server="socks5://127.0.0.1:9150" \
              https://ipinfo.io/ip \
              https://3g2upl4pq6kufc4m.onion/ &
      
  4. テスト終了

    コンテナ動作停止、削除
    # DOCKER_NAME=tor-socks-proxy
    docker stop ${DOCKER_NAME}
    docker rm ${DOCKER_NAME}
    
  5. (お好みで) Dockerコンテナをサービスに登録して、自動起動

    こぴぺ
    DOCKER_NAME=tor-socks-proxy
    DOCKER_CONTAINER_NAME=tor-socks-proxy
    
    # とりあえず起動させる
    docker run -d --name ${DOCKER_CONTAINER_NAME} -p 9150:9150 ${DOCKER_NAME}
    
    # systemdのファイル作成
    sudo sh -c "cat <<EOF > /lib/systemd/system/${DOCKER_CONTAINER_NAME}.service
    [Unit]
    Description=${DOCKER_CONTAINER_NAME} container
    Requires=docker.service
    After=docker.service
    
    [Service]
    Restart=always
    ExecStart=/usr/bin/docker start -a ${DOCKER_CONTAINER_NAME}
    ExecStop=/usr/bin/docker stop ${DOCKER_CONTAINER_NAME}
    
    [Install]
    WantedBy=multi-user.target
    EOF"
    
    # systemdの設定
    sudo systemctl daemon-reload
    sudo systemctl enable ${DOCKER_CONTAINER_NAME}.service
    sudo systemctl restart ${DOCKER_CONTAINER_NAME}.service
    
    # サービスが起動しているか?
    #sudo systemctl status ${DOCKER_CONTAINER_NAME}.service
    # なんちゃら、100%になっているか?
    #docker logs ${DOCKER_NAME}
    

おまけ

  • ほかからも、接続できるようにした場合(-p 9150:9150)、
    "~~\chrome.exe" --proxy-server="socks5://rpi_ip:9150" というかんじで、ショートカットを作れば、WindowsのChromeをTor経由で使える。
    image.png
mt08
ツイッターアカウントと紐づけてみた。[2019-11-26]
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした