# How to create a Yggdrasil hidden service on Caddy on Debian 10

first published: 2021-01-16

last updated: 2021-02-07

1. Install Yggdrasil.

`sudo apt install dirmngr`

`gpg --fetch-keys https://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/key.txt`

`gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add -`

`echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list`

`sudo apt update; sudo apt install yggdrasil`

2. Install the Caddy web server.

`echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list`

`sudo apt update; sudo apt install caddy -y`

3. Get the IP Yggdrasil generates for you.

`sudo systemctl start yggdrasil; sudo systemctl enable yggdrasil`

`sudo journalctl -xfe -u yggdrasil`

There will be a line that says "Your IPv6 address is". Copy the rest of that line somewhere safe.

Press the Control and C buttons on your keyboard at the same time to exit `journalctl`.

4. Configure Caddy to serve the hidden service.

Open `/etc/caddy/Caddyfile` as root with your favorite text editor.

Type the following in:

    http://[YGGDRASIL_IP_ADDRESS_HERE] {
    	root * /your/website/file/path/here
    	file_server
    	encode gzip
    }

The "http://" in front of the address is important as that tells Caddy to not try to enable HTTPS for that website. HTTPS is unnecessary for Yggdrasil hidden services as all traffic to and from the server is already encrypted in transit. Besides, Let's Encrypt wouldn't be able to issue a certificate for an IP address anyway.

5. Restart Caddy to apply your changes.

`sudo systemctl restart caddy`

6. Get some peers for Yggdrasil.

Open this page in a new tab on your browser. On your server, open `/etc/yggdrasil.conf` as root with your favorite text editor.

At the top of the configuration file will be a section that looks like this:

`Peers: []`

Pick some peers from the list and add them to that section of the file (one per line) so it now looks something like this:

      Peers:
      [
        tcp://50.236.201.218:56088
        tcp://lancis.iscute.moe:49273
        tcp://45.77.107.150:34660
        tls://longseason.1200bps.xyz:13122
        tcp://8.9.30.45:34371
        tls://107.189.4.167:42024
      ]

Substitute for the peers closest to your server geographically.

Save the file and close it.

`sudo systemctl restart yggdrasil`

CC BY-NC-SA 4.0 © Vane Vander