WHAT'S NEW?
Loading...

[TUTORIAL] Host a Static Website With Raspberry Pi for Free using the Dat Protocol

What is Dat?

Share, backup, and publish your filesystem. You can turn any folder on your computer into a dat. Dat scans your folder, allowing you to:
  • Track your files with automatic version history.
  • Share files with others over a secure peer to peer network.
  • Automate live backups to external HDs or remote servers.
  • Publish and share files with built in HTTP server.
First you must install Node.js

Just follow the steps below.
wget https://nodejs.org/dist/v8.6.0/node-v8.6.0-linux-armv7l.tar.gz
tar -xvf node-v8.6.0-linux-armv7l.tar.gz 
cd node-v8.6.0-linux-armv7l
Copy to /usr/local
sudo cp -R * /usr/local/
To check Node.js is properly installed and you have the right version, run the command node -v

Installing via npm

The Dat command line tool can be installed with npm:
npm install -g dat
Make sure you have node and npm installed first. 

Sharing Data

You can start sharing your website files with a single command:
dat share <dir>

<dir> is the path directory with your static website files. Use dat share mywebsitedir to create a dat and sync your files from your computer to other users. Dat scans your files inside <dir>, creating metadata in <dir>/.dat. Dat stores the public link, version history, and file information inside the dat folder.

Point your domain to your website, install dathttpd

A Web server for Dat and HTTPS.
Dat sites are hosted at public keys, which are the equivalent of IP addresses in the P2P network. The pubkeys are ugly, though! Wouldn't it be nice if your dats could have nice DNS shortnames, and also rehost over HTTPS for people still on legacy browsers? Follow these instructions
Create a config file .dathttpd.yml, 

letsencrypt:
  email: 'bob@foo.com'
  agreeTos: true
sites:
  mywebsite.com:
    url: dat://yourdaturl/
    datOnly: false
replace url with your DAT URL , after you must specify the path of the file .dathttpd.yml
In bash you can set the variable like this:
export DATHTTPD_CONFIG=/home/raspberry/
most other shells follow this convention, but not all. You can set it permanently in ~/.profile for bash (and as before, other shells have other locations). In the example /home/raspberry is the path where is the file.

Use the printenv command to print the names and values of all currently defined environment variables:
printenv 


Install dathttpd

# install build dependencies
sudo apt-get install libtool m4 automake

# install dathttpd 
npm install -g dathttpd

# give node perms to use ports 80 and 443
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``

# start dathttpd
sudo dathttpd
[sudo] password for raspberry:
Serving from /home/raspberry/.dathttpd
le.challenges[tls-sni-01].loopback should be defined as function (opts, domain, token, cb) { ... } and should prove (by external means) that the ACME server challenge 'tls-sni-01' will succeed
Handling ACME challenges and redirecting to https on plain port 80
Handling ACME challenges and serving https 443
Serving dat.local dat://yourdaturl/

To daemonify the server, stop the dathttpd process and then run:
# install a helper tool
sudo npm install -g add-to-systemd

# create a systemd entry for dathttpd
sudo add-to-systemd dathttpd --user $(whoami) $(which dathttpd)

# start the dathttpd service
sudo systemctl start dathttpd
raspberry@raspberry-desktop:~$ sudo systemctl status dathttpd
â dathttpd.service
   Loaded: loaded (/lib/systemd/system/dathttpd.service; enabled; vendor preset:
   Active: active (running) since mer 2017-09-27 14:35:12 CEST; 1s ago
 Main PID: 3318 (node)
   CGroup: /system.slice/dathttpd.service
           ââ3318 node /usr/local/bin/dathttpd

set 27 14:35:12 raspberry-desktop systemd[1]: Started dathttpd.service.

0 comments:

Post a Comment