{"id":13540953,"url":"https://github.com/beakerbrowser/dathttpd","last_synced_at":"2025-04-02T08:30:53.763Z","repository":{"id":57280867,"uuid":"80235151","full_name":"beakerbrowser/dathttpd","owner":"beakerbrowser","description":"Replaced by Homebase! See https://github.com/beakerbrowser/homebase.","archived":true,"fork":false,"pushed_at":"2018-07-17T21:48:14.000Z","size":271,"stargazers_count":279,"open_issues_count":12,"forks_count":35,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-12T01:23:32.899Z","etag":null,"topics":["dat","http","p2p","server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beakerbrowser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-27T18:40:48.000Z","updated_at":"2024-12-12T06:27:13.000Z","dependencies_parsed_at":"2022-09-19T20:10:32.112Z","dependency_job_id":null,"html_url":"https://github.com/beakerbrowser/dathttpd","commit_stats":null,"previous_names":["pfrazee/dathttpd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beakerbrowser%2Fdathttpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beakerbrowser%2Fdathttpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beakerbrowser%2Fdathttpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beakerbrowser%2Fdathttpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beakerbrowser","download_url":"https://codeload.github.com/beakerbrowser/dathttpd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246781880,"owners_count":20832924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dat","http","p2p","server"],"created_at":"2024-08-01T10:00:36.562Z","updated_at":"2025-04-02T08:30:53.365Z","avatar_url":"https://github.com/beakerbrowser.png","language":"JavaScript","readme":"# dathttpd\n\n---\n\nDatHTTPD has been replaced by [Homebase](https://github.com/beakerbrowser/homebase)! Same basic design, but more features and an easier-to-pronounce name.\n\n---\n\nA Web server for [Dat](https://datprotocol.com) and HTTPS.\n\nDat 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?\n\ndathttpd is for you!\n\n - Serve sites over Dat at `dat://{subdomain}.{yourdomain.com}`.\n - Rehost those sites over `https://{subdomain}.{yourdomain.com}`.\n - Get TLS certs automatically with Let's Encrypt.\n - (Optionally) Auto-redirect from https -\u003e dat.\n - [Metrics dashboard](#metrics-dashboard)\n\n## Getting started\n\n### Start hosting your website with Dat\n\nYou can use the [Dat CLI](https://www.npmjs.com/package/dat) or the [Beaker\nBrowser](https://github.com/beakerbrowser/beaker).\n\nAfter uploading your site to a Dat archive, identify the archive's URL. You'll\nneed this for your dathttpd config.\n\n### Update your DNS records\n\nCreate an A record that points to your server's IP address.\n\n### Firewall rules\n\nMake sure your server is accessible by port 80 (http), 443 (https), and 3282 (dat).\n\n## Usage\n\nOn your server, create a config file at `~/.dathttpd.yml` that follows this structure:\n\n```yaml\nletsencrypt:\n  email: 'bob@foo.com'\n  agreeTos: true\nsites:\n  my-site.com:\n    url: dat://1f968afe867f06b0d344c11efc23591c7f8c5fb3b4ac938d6000f330f6ee2a03/\n  my-other-site.com:\n    url: dat://ff34725120b2f3c5bd5028e4f61d14a45a22af48a7b12126d5d588becde88a93/\n```\n\nThen run\n\n```\n# install build dependencies\nsudo apt-get install libtool m4 automake libcap2-bin build-essential\n\n# install dathttpd (https://docs.npmjs.com/getting-started/fixing-npm-permissions)\nnpm install -g dathttpd\n\n# give node perms to use ports 80 and 443\nsudo setcap cap_net_bind_service=+ep `readlink -f \\`which node\\``\n\n# start dathttpd\ndathttpd\n```\n\nTo daemonify the server in Debian-based systems, stop the dathttpd process and\nthen run:\n\n```\n# install a helper tool\nnpm install -g add-to-systemd\n\n# create a systemd entry for dathttpd\nsudo add-to-systemd dathttpd --user $(whoami) $(which dathttpd)\n\n# start the dathttpd service\nsudo systemctl start dathttpd\n```\n\n## Config\n\nHere's an example `~/.dathttpd.yml`:\n\n```yaml\nports:\n  http: 80\n  https: 443\n  metric: 8089\ndirectory: ~/.dathttpd\nletsencrypt:\n  email: 'bob@foo.com'\n  agreeTos: true\nsites:\n  my-site.com:\n    url: dat://1f968afe867f06b0d344c11efc23591c7f8c5fb3b4ac938d6000f330f6ee2a03/\n    datOnly: false\n  my-other-site.com:\n    url: dat://ff34725120b2f3c5bd5028e4f61d14a45a22af48a7b12126d5d588becde88a93/\n    datOnly: true\n  my-proxy.com:\n    proxy: http://localhost:8080\n  my-old-site.com:\n    redirect: https://my-site.com\n```\n\n### ports.http\n\nThe port to serve the HTTP sites. Defaults to 80. (Optional)\n\nHTTP automatically redirects to HTTPS.\n\n### ports.https\n\nThe port to serve the HTTPS sites. Defaults to 443. (Optional)\n\n### ports.metric\n\nThe port to serve the prometheus metrics. Defaults to 8089. (Optional)\n\n### directory\n\nThe directory where dathttpd will store your Dat archive's files. Defaults to ~/.dathttpd. (Optional)\n\n### letsencrypt\n\nSettings for LetsEncrypt. If false or unset, HTTPS will be disabled.\n\n### letsencrypt.email\n\nThe email to send Lets Encrypt? notices to. (Required)\n\n### letsencrypt.agreeTos\n\nDo you agree to the terms of service of Lets Encrypt? (Required, must be true)\n\n### sites\n\nA listing of the sites to host. Each site is labeled (keyed) by the hostname you want the site to serve at.\n\nSites 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.\n\nYou'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.\n\n### sites.{hostname}.url\n\nThe Dat URL of the site to host.\n\n### sites.{hostname}.proxy\n\nThe HTTP URL of the site to proxy.\n\n### sites.{hostname}.redirect\n\nThe HTTP URL of the site to redirect traffic to.\n\n### sites.{hostname}.datOnly\n\nIf true, rather than serve the assets over HTTPS, dathttpd will serve a redirect to the dat:// location. Defaults to false. (Optional)\n\n### sites.{hostname}.hsts\n\nIf true, serve the [HSTS header](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security). You can specify how long the strict-transport rule lasts as the value. (parsed using [the ms module](https://www.npmjs.com/package/ms)). If `true` is given, will default to 7 days. Defaults to false. (Optional)\n\n## Command Line Flags\n\n  - `--config \u003cpath\u003e` use the config file at the given path instead of the default `~/.dathttpd.yml`. Overrides the value of the `DATHTTPD_CONFIG` env var.\n\n## Env Vars\n\n  - `DATHTTPD_CONFIG=cfg_file_path` specify an alternative path to the config than `~/.dathttpd.yml`\n  - `NODE_ENV=debug|staging|production` set to `debug` or `staging` to use the lets-encrypt testing servers.\n\n## Metrics Dashboard\n\nDatHTTPD has built-in support for [Prometheus](https://prometheus.io), which can be visualized by [Grafana](http://grafana.org/).\n\n![./grafana-screenshot.png](./grafana-screenshot.png)\n\nDatHTTPD 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.\n\nFollow these steps:\n\n 1. [Install Prometheus](https://prometheus.io/download/) on your server.\n 2. [Install Grafana](http://grafana.org/download/) on your server.\n 3. Update the `prometheus.yml` config.\n 4. Start prometheus and grafana.\n 5. Login to grafana.\n 6. Add prometheus as a data source to grafana. (It should be running at localhost:9090.)\n 7. Import [this grafana dashboard](./grafana-dashboard.json).\n\nYour prometheus.yml config should include have the scrape_configs set like this:\n\n```yml\nscrape_configs:\n  - job_name: 'prometheus'\n    static_configs:\n      - targets: ['localhost:9090']\n  - job_name: 'dathttpd'\n    static_configs:\n      - targets: ['localhost:8089']\n```\n\nReport any issues you have along the way!\n","funding_links":[],"categories":["JavaScript","Using Dat","http"],"sub_categories":["Hosting \u0026 Dat Management"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeakerbrowser%2Fdathttpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeakerbrowser%2Fdathttpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeakerbrowser%2Fdathttpd/lists"}