| 1 | ## HTTP Alt-Svc Example |
| 2 | |
| 3 | The Tor browser now supports `Alt-Svc` headers to be onion services as |
| 4 | [HTTP alternate services](https://tools.ietf.org/html/rfc7838) to traditional sites. |
| 5 | [This Cloudflare post](https://blog.cloudflare.com/cloudflare-onion-service/) explains how they use it. This example |
| 6 | shows how to do it yourself. Since |
| 7 | |
| 8 | Specifically, this example listens on all IPs on 80 for insecure HTTP requests. It also listens on an onion service for |
| 9 | insecure HTTP requests. Both services return `Alt-Svc` addresses to an onion service that is run securely. |
| 10 | |
| 11 | **NOTE: Only do the steps in this example if you are comfortable with and aware of the consequences.** |
| 12 | |
| 13 | ### Setup |
| 14 | |
| 15 | We're going to self-sign a certificate for use in the Tor browser. First, download `mkcert` and run: |
| 16 | |
| 17 | mkcert -install |
| 18 | |
| 19 | This will install a fake CA on your local machine that certs can be generated from. Remember the path it says the local |
| 20 | CA is at or run `mkcert -CAROOT` to get it back. We will use this "CA path" later. |
| 21 | |
| 22 | Now the CA must be added to the Tor browser. By default the Tor browser doesn't use the cert database so it cannot store |
| 23 | the overrides. To change this, go to `about:config` click through warning and change `security.nocertdb` to `false`. Now |
| 24 | that CAs can be added, go to `Options` (i.e. `about:preferences`) > `Privacy & Security` > `Certificates` section at the |
| 25 | bottom > `View Certificates...` > `Authorities` tab > `Import...` > choose `rootCA.pem` from the "CA path" from |
| 26 | earlier > check "Trust this CA to identify websites" and click `OK`. Restart the Tor browser. |
| 27 | |
| 28 | ### Running |
| 29 | |
| 30 | Point yor DNS to this machine's IP (or use start `ngrok http 80` via [ngrok.com](https://ngrok.com/)) |
| 31 | |
| 32 | TODO: the rest... |
| 33 | |
| 34 | TODO: alt-svc onions appear broken in TBB |