├── html
└── index.html
├── docker-compose.yml
└── README.md
/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
31 |
Thank you!
32 |
If you want to follow me, you can find me here: https://social.1xx.io/@nicd
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | services:
2 | tor:
3 | image: alpine:latest
4 | container_name: tor
5 | command: >
6 | sh -c "
7 | apk add --no-cache tor &&
8 | mkdir -p /var/lib/tor/hidden_service &&
9 | chmod 700 /var/lib/tor/hidden_service &&
10 | if [ ! -f /var/lib/tor/hidden_service/hostname ]; then
11 | echo 'HiddenServiceDir /var/lib/tor/hidden_service' >> /etc/tor/torrc &&
12 | echo 'HiddenServicePort 80 lighttpd:80' >> /etc/tor/torrc &&
13 | tor --quiet;
14 | else
15 | tor --quiet;
16 | fi"
17 | volumes:
18 | - ./tor/torrc:/etc/tor/torrc
19 | - ./tor/hidden_service:/var/lib/tor/hidden_service
20 | networks:
21 | - tor-network
22 |
23 | lighttpd:
24 | image: lighttpd:alpine
25 | container_name: lighttpd
26 | volumes:
27 | - ./html:/var/www/html
28 | ports:
29 | # - "80:80" # Expose the web server on port 80 to make the site accessible on the regular web.
30 | # - "443:443" # Expose the web server on port 443 to make the site accessible on the regular web.
31 | networks:
32 | - tor-network
33 |
34 | networks:
35 | tor-network:
36 | driver: bridge
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tor-Lighttpd-Onion
2 | This project provides a setup using Docker to create a service running `Tor` and a `lighttpd` web server. The `.onion` address remains persistent between container restarts.
3 |
4 | ## Project Structure
5 |
6 | The project directory should look like this:
7 |
8 | ```bash
9 | tor-lighttpd-onion/
10 | │
11 | ├── docker-compose.yml
12 | ├── tor/
13 | │ ├── torrc
14 | │ └── hidden_service/
15 | │ └── hostname (automatically generated)
16 | └── html/
17 | └── index.html
18 | └── page2.html
19 | └── page3.html
20 | └── eccecc.html
21 | ```
22 |
23 |
24 | ## 1. Create the `docker-compose.yml` File
25 |
26 | Here is an example of a `docker-compose.yml` file:
27 |
28 | ```yaml
29 | services:
30 | tor:
31 | image: alpine:latest
32 | container_name: tor
33 | command: >
34 | sh -c "
35 | apk add --no-cache tor &&
36 | mkdir -p /var/lib/tor/hidden_service &&
37 | chmod 700 /var/lib/tor/hidden_service &&
38 | if [ ! -f /var/lib/tor/hidden_service/hostname ]; then
39 | echo 'HiddenServiceDir /var/lib/tor/hidden_service' >> /etc/tor/torrc &&
40 | echo 'HiddenServicePort 80 lighttpd:80' >> /etc/tor/torrc &&
41 | tor --quiet;
42 | else
43 | tor --quiet;
44 | fi"
45 | volumes:
46 | - ./tor/torrc:/etc/tor/torrc
47 | - ./tor/hidden_service:/var/lib/tor/hidden_service
48 | networks:
49 | - tor-network
50 |
51 | lighttpd:
52 | image: lighttpd:alpine
53 | container_name: lighttpd
54 | volumes:
55 | - ./html:/var/www/html
56 | ports:
57 | # - "80:80" # Expose the web server on port 80 to make the site accessible on the regular web.
58 | # - "443:443" # Expose the web server on port 443 to make the site accessible on the regular web.
59 | networks:
60 | - tor-network
61 |
62 | networks:
63 | tor-network:
64 | driver: bridge
65 | ```
66 |
67 | ## 2. Configure the torrc File
68 |
69 | In this setup, the torrc file will be very very very simple. The main configuration is managed via the command section in the Docker Compose file. The torrc file will have only basic settings, with other settings dynamically added by the container:
70 |
71 |
72 | ```bash
73 | # Torrc base config (other settings added by container)
74 | Log notice stdout
75 | ```
76 |
77 | ## 3. Create the hidden_service Directory
78 |
79 | The `hidden_service` directory will contain the `hostname` file, which will be automatically generated by Tor during the first execution.
80 | This file will be reused on subsequent container starts, ensuring the .onion address remains the same. It's important to map this directory as a volume in Docker Compose to persist the .onion address across container restarts.
81 |
82 | ## 4. Configure lighttpd
83 |
84 | The html directory will contain the website you want to serve. Simply add an index.html file with the desired content for example.
85 |
86 | ## 5. Start the Service
87 |
88 | Now you can start the service with:
89 |
90 | ```bash
91 | docker compose up -d
92 | ```
93 |
94 | **On the first run, the Tor container will generate a new .onion address and save it in the hostname file. On subsequent runs, the same address will be reused.**
95 |
96 | ## 6. Access the .onion Address
97 |
98 | After starting, you can view the .onion address in the `tor/hidden_service/hostname` file. This is the address you will use to access your site via the Tor browser.
99 |
100 |
101 | ## If you don't have Docker and Docker Compose installed, follow these links:
102 |
103 | [Install Docker](https://docs.docker.com/engine/install/)
104 |
105 | [Install Docker Compose](https://docs.docker.com/compose/install/)
106 |
107 | ## Troubleshooting
108 |
109 | Ensure your Docker and Docker Compose versions are up to date. If the .onion address is not persistent, check the hidden_service directory permissions and ensure it's correctly mapped in the Docker Compose file.
110 |
--------------------------------------------------------------------------------