[tor-commits] [community/master] Add instructions for Caddy 2

gus at torproject.org gus at torproject.org
Fri Oct 16 03:01:35 UTC 2020


commit 2810a3c8724c9df184c3826bd7c33f4779237cf1
Author: Amin Shah Gilani <amin at gilani.me>
Date:   Tue Jul 14 05:58:10 2020 +0500

    Add instructions for Caddy 2
---
 .../advanced/onion-location/contents.lr            | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/content/onion-services/advanced/onion-location/contents.lr b/content/onion-services/advanced/onion-location/contents.lr
index efd5e0c..b1e1dcf 100644
--- a/content/onion-services/advanced/onion-location/contents.lr
+++ b/content/onion-services/advanced/onion-location/contents.lr
@@ -184,6 +184,36 @@ To test if the Onion-Location is working, fetch the web site HTTP headers, for e
 Look for `onion-location` entry and the onion service address.
 Or, open the web site in Tor Browser and a purple pill will appear in the address bar.
 
+### Caddy
+
+Caddy features [automatic HTTPS](https://caddyserver.com/docs/automatic-https)
+by default, so it provisions your TLS certificate and takes care of
+HTTP-to-HTTPS redirection for you. If you're using Caddy 2, to include an
+Onion-Location header, add the following declaration in your Caddyfile:
+
+```
+header Onion-Location http://<your-onion-address>.onion{path}
+```
+
+If you're running a static site and have the onion address in a `$TOR_HOSTNAME`
+environment variable, your Caddyfile will look like this:
+
+```
+your-website.tld
+
+header Onion-Location http://{$TOR_HOSTNAME}{path}
+root * /var/www
+file_server
+```
+
+**Testing it out:** Test it out with:
+
+```
+curl -I https://your-website.tld
+```
+
+and look for the `onion-location` line.
+
 ### Using an HTML `<meta>` attribute
 
 The identical behaviour of Onion-Location includes the option of defining it as a HTML `<meta>` http-equiv attribute.





More information about the tor-commits mailing list