Skip to content

Commit 7bc2479

Browse files
Improve README.md
1 parent aae0081 commit 7bc2479

File tree

1 file changed

+38
-75
lines changed

1 file changed

+38
-75
lines changed

README.md

Lines changed: 38 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
[![Docker Hub badge](http://dockeri.co/image/peterdavehello/tor-socks-proxy)](https://hub.docker.com/r/peterdavehello/tor-socks-proxy/)
1212

13-
The super easy way to setup a [Tor](https://www.torproject.org) [SOCKS5](https://en.wikipedia.org/wiki/SOCKS#SOCKS5) [proxy server](https://en.wikipedia.org/wiki/Proxy_server) inside a [Docker](https://en.wikipedia.org/wiki/Docker_(software)) [container](https://en.wikipedia.org/wiki/Container_(virtualization)) without relay/exit feature.
13+
The super easy way to set up a [Tor](https://www.torproject.org) [SOCKS5](https://en.wikipedia.org/wiki/SOCKS#SOCKS5) [proxy server](https://en.wikipedia.org/wiki/Proxy_server) inside a [Docker](https://en.wikipedia.org/wiki/Docker_(software)) [container](https://en.wikipedia.org/wiki/Container_(virtualization)), without Tor relay/exit node function enabled.
1414

1515
## Docker image Repository
1616

@@ -27,97 +27,60 @@ Use the prefix `ghcr.io/` if you prefer to use GitHub Container Registry.
2727

2828
## Usage
2929

30-
1. Setup the proxy server at the **first time**
30+
### First-Time Setup
3131

32-
```sh
33-
docker run -d --restart=always --name tor-socks-proxy -p 127.0.0.1:9150:9150/tcp peterdavehello/tor-socks-proxy:latest
34-
```
32+
```sh
33+
docker run -d --restart=always --name tor-socks-proxy -p 127.0.0.1:9150:9150/tcp peterdavehello/tor-socks-proxy:latest
34+
```
3535

36-
- With parameter `--restart=always` the container will always start on daemon startup, which means it'll automatically start after system reboot.
37-
- Use `127.0.0.1` to limit the connections from localhost, do not change it unless you know you're going to expose it to a local network or to the Internet.
38-
- Change to first `9150` to any valid and free port you want, please note that port `9050`/`9150` may already taken if you are also running other Tor client, like TorBrowser.
39-
- Do not touch the second `9150` as it's the port inside the docker container unless you're going to change the port in Dockerfile.
36+
- `--restart=always`: This ensures the container automatically restarts whenever the system reboots.
37+
- `-p 127.0.0.1:9150:9150/tcp`: This binds the container to localhost, and you should not change this IP unless you want to expose the proxy to a local network or the Internet.
38+
- You can change the first `9150` to any available port. Please note that ports `9050`/`9150` may be occupied if you are running another Tor client like TorBrowser.
4039

41-
If you want to expose Tor's DNS port, also add `-p 127.0.0.1:53:8853/udp` in the command, see [DNS over Tor](#dns-over-tor) for more details.
40+
### Start or stop an existing Instance manually
4241

43-
If you already setup the instance before *(not the first time)* but it's in stopped state, you can just start it instead of creating a new one:
42+
```sh
43+
docker start tor-socks-proxy
44+
```
4445

45-
```sh
46-
docker start tor-socks-proxy
47-
```
46+
```sh
47+
docker stop tor-socks-proxy
48+
```
4849

49-
2. Make sure it's running, it'll take a short time to bootstrap
50+
### Checking the Proxy Status and logs
5051

51-
```sh
52-
$ docker logs tor-socks-proxy
53-
.
54-
.
55-
.
56-
Jan 10 01:06:59.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
57-
Jan 10 01:07:00.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
58-
Jan 10 01:07:02.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
59-
Jan 10 01:07:02.000 [notice] Bootstrapped 100%: Done
60-
```
52+
```sh
53+
docker logs tor-socks-proxy
54+
```
6155

62-
3. Configure your client to use it, target on `127.0.0.1` port `9150`(Or the other port you setup in step 1)
56+
### Configuring a Client to Use the Proxy
6357

64-
Take `curl` as an example, if you'd like to checkout what's your IP address via Tor network, using one of the following IP checking services:
58+
```sh
59+
curl --socks5-hostname 127.0.0.1:9150 https://ipinfo.tw/ip
60+
```
6561

66-
- <https://ipinfo.tw/ip> ([My another side project](https://github.com/PeterDaveHello/ipinfo.tw/))
67-
- <https://ipinfo.io/ip>
68-
- <https://icanhazip.com>
69-
- <https://ipecho.net/plain>
62+
### Stopping the Proxy
7063

71-
```sh
72-
curl --socks5-hostname 127.0.0.1:9150 https://ipinfo.tw/ip
73-
```
64+
```sh
65+
docker stop tor-socks-proxy
66+
```
7467

75-
Take `ssh` and `nc` as an example, connect to a host via Tor:
68+
## IP Renewal
7669

77-
```sh
78-
ssh -o ProxyCommand='nc -x 127.0.0.1:9150 %h %p' target.hostname.blah
79-
```
70+
By default, Tor automatically changes IPs every 10 minutes. You can manually renew the IP by restarting the container:
8071

81-
Tor Project also have an API if you want to be sure if you'on Tor network: <https://check.torproject.org/api/ip>, the result would look like:
82-
83-
```json
84-
{"IsTor":true,"IP":"151.80.58.219"}
85-
```
86-
87-
4. After using it, you can turn it off
88-
89-
```sh
90-
docker stop tor-socks-proxy
91-
```
92-
93-
## IP renewal
94-
95-
- Tor changes circuit automatically every 10 minutes by default, which usually bring you the new IP address, it's affected by `MaxCircuitDirtiness` config, you can override it with your own `torrc`, or edit the config file and restart the container. See the official [manual](https://www.torproject.org/docs/tor-manual.html.en) for more details.
96-
97-
- To manually renew the IP that Tor gives you, simply restart your docker container to open a new circuit:
98-
99-
```sh
100-
docker restart tor-socks-proxy
101-
```
102-
103-
Just note that all the connections will be terminated and need to be reestablished.
72+
```sh
73+
docker restart tor-socks-proxy
74+
```
10475

10576
## DNS over Tor
10677

107-
If you publish the DNS port in the first step of [Usage](#usage) section, you can query DNS request over Tor
108-
109-
The DNSPort here is set to `8853` by default, but not the common `53`, because non-privileged port is preferred, and then [`libcap`](https://pkgs.alpinelinux.org/package/edge/main/x86/libcap)/[`CAP_NET_BIND_SERVICE` capability](https://man7.org/linux/man-pages/man7/capabilities.7.html) won't be needed, which is more *[Alpine Linux](https://alpinelinux.org/about/)(Small. Simple. Secure.)*
110-
111-
You can still expose the port to `53` for outside the container by the parameter `-p 127.0.0.1:53:8853/udp`. `nslookup` also supports to specify the port to `8853` by `-port=8853`, e.g. `nslookup -port=8853 ipinfo.tw 127.0.0.1`
112-
113-
This port only handles `A`, `AAAA`, and `PTR` requests, see details on [official manual](https://www.torproject.org/docs/tor-manual.html.en)
114-
115-
Set the DNS server to `127.0.0.1` (Or another IP you set), use [macvk/dnsleaktest](https://github.com/macvk/dnsleaktest) or go to one of the following DNS leaking test websites to verify the result:
78+
Publish DNS port during setup to query DNS requests over Tor:
11679

117-
- DNS leak test: <https://www.dnsleaktest.com>
118-
- IP Leak Tests: <https://ipleak.org/>
119-
- IP/DNS Detect: <https://ipleak.net/>
80+
```sh
81+
docker run -d --restart=always --name tor-socks-proxy -p 127.0.0.1:9150:9150/tcp -p 127.0.0.1:53:8853/udp peterdavehello/tor-socks-proxy:latest
82+
```
12083

121-
## Note
84+
## Support Tor Project
12285

123-
**For the Tor project sustainability, I strongly encourage you to help [setup Tor bridge/exit nodes](https://trac.torproject.org/projects/tor/wiki/TorRelayGuide)([**script**](https://github.com/PeterDaveHello/ubuntu-tor-simply-setup)) and [donate](https://donate.torproject.org/) money to the Tor project *(Not this proxy project)* when you have the ability/capacity!**
86+
Support the Tor project by [setting up Tor bridge/exit nodes](https://trac.torproject.org/projects/tor/wiki/TorRelayGuide) and [donating](https://donate.torproject.org/).

0 commit comments

Comments
 (0)