• This repository has been archived on 27/Dec/2022
  • Stars
    star
    280
  • Rank 147,492 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Replaced by Homebase! See https://github.com/beakerbrowser/homebase.

dathttpd


DatHTTPD has been replaced by Homebase! Same basic design, but more features and an easier-to-pronounce name.


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?

dathttpd is for you!

  • Serve sites over Dat at dat://{subdomain}.{yourdomain.com}.
  • Rehost those sites over https://{subdomain}.{yourdomain.com}.
  • Get TLS certs automatically with Let's Encrypt.
  • (Optionally) Auto-redirect from https -> dat.
  • Metrics dashboard

Getting started

Start hosting your website with Dat

You can use the Dat CLI or the Beaker Browser.

After uploading your site to a Dat archive, identify the archive's URL. You'll need this for your dathttpd config.

Update your DNS records

Create an A record that points to your server's IP address.

Firewall rules

Make sure your server is accessible by port 80 (http), 443 (https), and 3282 (dat).

Usage

On your server, create a config file at ~/.dathttpd.yml that follows this structure:

letsencrypt:
  email: '[email protected]'
  agreeTos: true
sites:
  my-site.com:
    url: dat://1f968afe867f06b0d344c11efc23591c7f8c5fb3b4ac938d6000f330f6ee2a03/
  my-other-site.com:
    url: dat://ff34725120b2f3c5bd5028e4f61d14a45a22af48a7b12126d5d588becde88a93/

Then run

# install build dependencies
sudo apt-get install libtool m4 automake libcap2-bin build-essential

# install dathttpd (https://docs.npmjs.com/getting-started/fixing-npm-permissions)
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
dathttpd

To daemonify the server in Debian-based systems, stop the dathttpd process and then run:

# install a helper tool
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

Config

Here's an example ~/.dathttpd.yml:

ports:
  http: 80
  https: 443
  metric: 8089
directory: ~/.dathttpd
letsencrypt:
  email: '[email protected]'
  agreeTos: true
sites:
  my-site.com:
    url: dat://1f968afe867f06b0d344c11efc23591c7f8c5fb3b4ac938d6000f330f6ee2a03/
    datOnly: false
  my-other-site.com:
    url: dat://ff34725120b2f3c5bd5028e4f61d14a45a22af48a7b12126d5d588becde88a93/
    datOnly: true
  my-proxy.com:
    proxy: http://localhost:8080
  my-old-site.com:
    redirect: https://my-site.com

ports.http

The port to serve the HTTP sites. Defaults to 80. (Optional)

HTTP automatically redirects to HTTPS.

ports.https

The port to serve the HTTPS sites. Defaults to 443. (Optional)

ports.metric

The port to serve the prometheus metrics. Defaults to 8089. (Optional)

directory

The directory where dathttpd will store your Dat archive's files. Defaults to ~/.dathttpd. (Optional)

letsencrypt

Settings for LetsEncrypt. If false or unset, HTTPS will be disabled.

letsencrypt.email

The email to send Lets Encrypt? notices to. (Required)

letsencrypt.agreeTos

Do you agree to the terms of service of Lets Encrypt? (Required, must be true)

sites

A listing of the sites to host. Each site is labeled (keyed) by the hostname you want the site to serve at.

Sites can either host dat archives or proxy to a URL. To make a dat-site, set the url attribute. To make a proxy, set the proxy attribute.

You'll need to configure the DNS entry for the hostname to point to the server. For instance, if using site.myhostname.com, you'll need a DNS entry pointing site.myhostname.com to the server.

sites.{hostname}.url

The Dat URL of the site to host.

sites.{hostname}.proxy

The HTTP URL of the site to proxy.

sites.{hostname}.redirect

The HTTP URL of the site to redirect traffic to.

sites.{hostname}.datOnly

If true, rather than serve the assets over HTTPS, dathttpd will serve a redirect to the dat:// location. Defaults to false. (Optional)

sites.{hostname}.hsts

If true, serve the HSTS header. You can specify how long the strict-transport rule lasts as the value. (parsed using the ms module). If true is given, will default to 7 days. Defaults to false. (Optional)

Command Line Flags

  • --config <path> use the config file at the given path instead of the default ~/.dathttpd.yml. Overrides the value of the DATHTTPD_CONFIG env var.

Env Vars

  • DATHTTPD_CONFIG=cfg_file_path specify an alternative path to the config than ~/.dathttpd.yml
  • NODE_ENV=debug|staging|production set to debug or staging to use the lets-encrypt testing servers.

Metrics Dashboard

DatHTTPD has built-in support for Prometheus, which can be visualized by Grafana.

./grafana-screenshot.png

DatHTTPD exposes its metrics at port 8089. Prometheus periodically scrapes the metrics, and stores them in a database. Grafana provides a nice dashboard. It's a little daunting at first, but setup should be relatively painless.

Follow these steps:

  1. Install Prometheus on your server.
  2. Install Grafana on your server.
  3. Update the prometheus.yml config.
  4. Start prometheus and grafana.
  5. Login to grafana.
  6. Add prometheus as a data source to grafana. (It should be running at localhost:9090.)
  7. Import this grafana dashboard.

Your prometheus.yml config should include have the scrape_configs set like this:

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
  - job_name: 'dathttpd'
    static_configs:
      - targets: ['localhost:8089']

Report any issues you have along the way!

More Repositories

1

beaker

An experimental peer-to-peer Web browser
JavaScript
6,750
star
2

homebase

Self-deployable tool for hosting hyper:// websites
JavaScript
406
star
3

webdb

The Web is your database.
JavaScript
399
star
4

fritter

A peer-to-peer social feed app. (proof of concept)
JavaScript
364
star
5

hashbase

A Dat-hosting service for multiple users
JavaScript
239
star
6

explore

A curated list of peer-to-peer websites and apps
HTML
181
star
7

unwalled.garden

Schemas for a p2p social-media network built on the Dat Web.
HTML
131
star
8

dat-photos-app

A peer-to-peer photos app
JavaScript
86
star
9

libfritter

Methods for Fritter, a Dat-based Twitter clone
JavaScript
47
star
10

beaker-core

Beaker browser's core software [outdated]
JavaScript
45
star
11

pauls-dat-api

Library of functions that make working with dat / hyperdrive easier.
JavaScript
44
star
12

beaker.social

A social networking app built on Beaker's unwalled.garden open standards.
JavaScript
40
star
13

bkr

Beaker headless runtime for the hyper:// space network.
JavaScript
39
star
14

beakerbrowser.com

Source code for https://beakerbrowser.com
HTML
39
star
15

dat-node

A toolkit for writing Dat-based services in nodejs
JavaScript
37
star
16

dat-rssreader-app

Read RSS feeds for blogs hosted over dat://
JavaScript
25
star
17

dat-archive-map-reduce

Index files in Dat archives with map-reduce to create queryable data views.
JavaScript
23
star
18

beaker.dev

Developer portal for templates, tutorials, and news
JavaScript
19
star
19

dat-pinning-service-client

Client API for Dat pinning services
JavaScript
14
star
20

social

Peer-to-peer social media
JavaScript
13
star
21

dat-ephemeral-ext-msg

Methods for DEP-0000: Ephemeral Message (Extension Message)
JavaScript
11
star
22

beaker-profiles-api

An API for reading and writing profile archives as used by Beaker.
JavaScript
11
star
23

beaker-browser.gitbook.io

This repo mirrors the content in beaker-browser.gitbook.io
11
star
24

dat-editor-app

A simple but well-featured code editor
JavaScript
11
star
25

beaker.network

A social aggregator application
JavaScript
10
star
26

docs.beakerbrowser.com

Beaker Browser documentation site
JavaScript
9
star
27

p2p-web-workshop

A collection of resources for running a peer-to-peer Web workshop
9
star
28

hyperdrive.network

An application for viewing and modifying Hyperdrives. Requires a Hyperdrive-enabled browser.
JavaScript
9
star
29

webterm

Specs and discussions for the Webterm environment
9
star
30

userlist

A simple service for listing your profile drive under your Twitter username.
JavaScript
8
star
31

beaker-uplink

Peer-to-peer bookmark sharing.
JavaScript
8
star
32

beaker-sidebar-app

Web application that drives Beaker's sidebar view
JavaScript
8
star
33

beaker-editor-app

In-browser editor application.
JavaScript
8
star
34

dat-legacy-tools

Tools to access legacy dats stored in Beaker
JavaScript
7
star
35

pauls-dat-api2

DatArchive implementation for Dat 2.0
JavaScript
7
star
36

beaker-reader

Publish and read blogposts.
JavaScript
7
star
37

dat-wysiwywiki-app

A wiki app with a wysiwyg interface
JavaScript
7
star
38

beaker-compare-app

A builtin app for comparing, diffing, and merging two dats
JavaScript
6
star
39

pauls-hyper-mirror

A simple seeding servce
JavaScript
6
star
40

beaker-user-website-template

The template for new user websites.
JavaScript
5
star
41

beaker-library-app

The Beaker "Library" app
JavaScript
5
star
42

beaker.cloud

An open-source dat server that scales
5
star
43

record-protocols-spec

(Dead Spec) A standard for building interoperable applications on the Web.
5
star
44

pauls-embedded-analytics

A sqlite-backed embedded analytics module for nodejs.
JavaScript
5
star
45

beaker-search-app

The Beaker "Search" app
JavaScript
5
star
46

beaker-virtual-fs

An object-oriented files interface used by Beaker to render the user's filesystem
JavaScript
5
star
47

dat-serve-resolve-path

Beaker's method to find the file to serve in dat:// requests
JavaScript
4
star
48

dat-nexus-app

A social feeds and profiles application
JavaScript
4
star
49

beaker-bookmarks-app

The Beaker "Bookmarks" app
JavaScript
4
star
50

beaker-app-stdlib

Assets which are reused across Beaker apps
JavaScript
4
star
51

viewer-apps

Beaker's builtin hyperdrive-viewer applications
JavaScript
3
star
52

hypercloud-ui-hashbase

Hashbase UI module for hypercloud [DEPRECATED]
CSS
3
star
53

library-tools

Module for managing the library.json file (spec: beakerbrowser.com/library)
JavaScript
3
star
54

beaker-error-constants

Module containing the errors used by beaker and its submodules
JavaScript
3
star
55

basic-user-site-template

Template used to create new user sites
JavaScript
3
star
56

uwg-bash

Bash CLI tools for reading/writing Unwalled Garden data
3
star
57

beaker-start-app

The Beaker "Start Page" app
JavaScript
2
star
58

beaker-analytics-server

Server to collect Beaker usage pings.
JavaScript
2
star
59

dat-workshop-server

A server for the "dat workshop" application (created for the Decentralized Web Summit 2018)
HTML
2
star
60

datignore

A module for reading and using .datignore files
JavaScript
2
star
61

builtin-pages-lib

Some common library code for Beaker's builtin pages.
JavaScript
2
star
62

beaker-index

An indexer driven from the beaker userlist
JavaScript
2
star
63

beaker-profile-app

The Beaker "Profile" App
JavaScript
2
star
64

beaker-feed-app

The Beaker "Feed" App
JavaScript
2
star
65

dat-session-data-ext-msg

Methods for DEP-0006: Session Data (Extension Message)
JavaScript
2
star
66

discussions

Repo for having org-wide discussions.
2
star
67

dat-archive-file-diff

Get line-by-line diffs of text files in Dat archives
JavaScript
1
star
68

dat-nexus-api

API for interacting with Dat Nexus profiles
JavaScript
1
star
69

simple-cloud-announcer

A fork of discovery-swarm that announces a peer and waits for connections.
JavaScript
1
star
70

assets

Images, logos, etc
1
star
71

site-schema.org

A machine-readable description format used to validate and describe the file structures of websites.
1
star