summaryrefslogtreecommitdiffstats
path: root/wiki/src/doc/advanced_topics/http_server.mdwn
blob: 34b4f880a437cdc31941d6fa43c62c83274d6f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
[[!meta title="How to serve files over HTTP behind a Tor Hidden Service"]]

This method uses '[thttpd](http://acme.com/software/thttpd/)' -  the
tiny/turbo/throttling HTTP server. Multiple Hidden Service instances can be run
simultaneously but that is beyond the scope of this documentation. The
URL-traffic-based throttling feature can be added by editing the
`/etc/thttpd/thttpd.conf` configuration file once 'thttpd' is installed - see
the [Throttling](http://acme.com/software/thttpd/thttpd_man.html#THROTTLING)
section of the 'thttpd' man page for more information.

**Note**: for a simpler file sharing alternative,
[OnionShare](https://onionshare.org/) is now available from
[Debian](https://packages.debian.org/sid/onionshare).

1. Start Tails on a device with a persistent volume. At the Tails greeter: Use
persistence, more options - set
[administration](https://tails.boum.org/doc/first_steps/startup_options/administration_password/)
password. Connect to the Internet and open the Tor browser.

2. Download the 'thttpd' package for the appropriate architecture (for example
i386) from [Debian](https://packages.debian.org/squeeze/thttpd), save the
package to `/home/amnesia/Persistent`.

3. Create an `index.html` and any other files you need for the Hidden Service in
a new directory `/home/amnesia/Persistent/www`. (*Take a look at*
[w3schools](http://www.w3schools.com/html/html_examples.asp) *for some HTML
basics.*)

4. Create a text file in `/home/amnesia/Persistent`. Copy and paste the
following code, then save as `ttt`.

        #!/bin/bash
        dpkg -i /home/amnesia/Persistent/thttpd_2.25b-11_i386.deb
        ## Edit "2.25b-11_i386" if different
        echo "ENABLED=yes" > /etc/default/thttpd
        cp -R /home/amnesia/Persistent/www /var
        chmod 755 /var/www
        chmod -R a+r /var/www/* 
        /etc/init.d/thttpd start
        echo -n "HiddenServiceDir /var/lib/tor/hidden_service/
        HiddenServicePort 80 " >> /etc/tor/torrc
        hostname -I >> /etc/tor/torrc
        #cp -R /home/amnesia/Persistent/hidden_service /var/lib/tor
        killall -HUP tor
        sleep 5
        cat /var/lib/tor/hidden_service/hostname

5. This procedure uses the command line. Open the
[root](https://tails.boum.org/doc/first_steps/startup_options/administration_password)
terminal and execute the following commands:

        chmod 755 /home/amnesia/Persistent/ttt
        /home/amnesia/Persistent/ttt

6. The last line of the terminal output is an automatically generated
`hidden_service` URL: `[16-char-base32].onion`  Copy (Shift+Ctrl+C) and paste
this into the Tor browser address bar - `index.html` loads.

7. To save this URL, copy the `hidden_service` directory containing the
`hostname` and `private_key` files to the persistent volume:

        cp -R /var/lib/tor/hidden_service /home/amnesia/Persistent

To use a previously saved Hidden Service
========================================

1. If the required the `hidden_service` directory is on *a different* Tails USB,
unlock and mount this USB with [Disk
Utilty](https://tails.boum.org/doc/encryption_and_privacy/encrypted_volumes)
then copy the directory to the 'live' USB:

        cp -R /media/TailsData/Persistent/hidden_service /home/amnesia/Persistent

2. Copy the `hidden_service` directory for the `torrc` configuration.

        cp -R /home/amnesia/Persistent/hidden_service /var/lib/tor

3. Check the directory ownership is `debian-tor`

        ls -l /var/lib/tor | grep hidden_service

    and fix if neccessary.

        chown debian-tor /var/lib/tor/hidden_service

4. Request Tor to re-read its configuration.

        killall -HUP tor

5. Print the URL of this previously saved `hidden_service` address,

        cat /var/lib/tor/hidden_service/hostname

    then copy (Shift+Ctrl+C) and paste this into the Tor browser address bar - `index.html` loads.

##### To continue the same Hidden Service after restarting Tails

1. The 'thttpd' package, `www` directory, `ttt` script and the `hidden_service`
directory are in the persistent volume. Uncomment (delete the `#` in) the
following line in `ttt` and save. This can of course be done before shutdown.

        #cp -R /home/amnesia/Persistent/hidden_service /var/lib/tor

2. Open the Tor browser.

3. Execute `ttt`.

[//]: # (exit-1@riseup.net)