June 6, 2020
The goal of this guide is to have clear and easy to follow best practices for deploying your urbit to a server you control in the cloud. This guide uses Digital Ocean as the cloud provider because DO focuses on this kind of use case (individual devs running something for themselves) and it's what I personally use.
Most Urbit users start out running their ship on their laptop in order to play with it, but this means when your laptop is offline your urbit is offline too (and can't get updates or keep hosting a group). You can also only access your urbit from that one laptop. In order to access your urbit from anywhere and any device, you need it running on a computer that's always online and accessible from your other devices. The way to do this is hosting it somewhere.
If you want a hosted urbit, but don't want to manage it yourself you can sign up for hosting on tlon.network. If you want to host your urbit on a spare computer that's always online on your home network check out Native Planet and their software that makes this easy (using tailscale is another option for this approach). For everyone else, running on Digital Ocean is a good option and this guide wil help you do that.
This guide assumes you're running macOS or linux on your local machine.
Your own domain will make accessing your urbit a lot easier (it'll also allow you to secure things with a Let's Encrypt cert). Domains are relatively inexpensive and since this guide is about best practices I'm making it a required step.
There are a lot of domain name registrars you can use, this guide suggests gandi.net because that's the one I use. From there you can search for and register a domain that you like.
Once you've registered your domain you'll need to configure it to use Digital Ocean for DNS. The following steps are done on the Gandi website.
ns1.digitalocean.comns2.digitalocean.comns3.digitalocean.comWith our domain in place we're now ready to actually log into the box and start to configure the server itself.
$ ssh root@your_server_ip
# adduser sammy
adduser asks you don't matter, hit enter to skip them.# usermod -aG sudo sammy
/.ssh:
# rsync --archive --chown=sammy:sammy ~/.ssh /home/sammy
ssh sammy@your_server_ip from your local machine in a new terminal window.ssh sammy@your_domain from a new terminal on your local machine.sudo when necessary.Continuing to follow the DO docs we're going to configure the ufw firewall.
$ sudo ufw app list
$ sudo ufw allow OpenSSH
$ sudo ufw allow 32123/udp
$ sudo ufw enable
$ sudo ufw status
Nginx is a webserver we're going to use as a reverse proxy. All incoming traffic to our Digital Ocean droplet will pass through Nginx and from there to your urbit. This allows us to lock everything else down and secure just that entry point.
$ sudo apt update
$ sudo apt install nginx
$ sudo ufw allow 'Nginx Full'
$ sudo ufw status
$ systemctl status nginx
$ sudo systemctl restart nginx
$ sudo systemctl reload nginx
Now we're going to configure Nginx so it serves up your urbit traffic securely.
sites-available directory:
$ cd /etc/nginx/sites-available
$ sudo vim your_domain
example.com without www or https.):
server {
server_name your_domain;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Forwarded for=$remote_addr;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
sites-enabled for Nginx:
$ sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/your_domain
$ sudo nginx -s reload
Now that we've got the Nginx reverse proxy installed we're going to get a Let's Encrypt SSL cert for it and configure it to automatically renew.
$ sudo apt install python3-certbot-nginx
$ sudo certbot --nginx -d your_domain
Note: If this fails it may be because your DNS change has not propagated which can take 12-24 hours.
https://your_domain, you should see a secure certificate.$ sudo certbot renew --dry-run
Finally we're ready to install Urbit on your very own server. This part is actually pretty easy, if you haven't installed Urbit locally then the instructions are the exact same as the ones in the Urbit getting started guide. If you have a local ship already we'll send your local ship up.
|exit in dojo.$ tar -zcvf <ship_dir_name>.tar.gz <ship_dir_name>
$ scp <ship_dir_name>.tar.gz your_user@your_domain:/home/your_user
$ ssh your_user@your_domain
$ tar -zxvf <ship_dir_name>.tar.gz
$ ./<ship_dir_name>/.run -p 32123
.run will fail because you need to dock the linux binary instead of the macOS binary. To do that, you'll want to download the linux binary from the getting started guide and follow the instructions linked in Step 5 on that page to dock the linux binary.https://your_domain, if everything is working properly you should see a login page.+code in dojo like normal and you should see all of your applications.Finally, to leave your urbit running after you disconnect we can leave it in a Screen session. This is just a way to leave applications running in the background and then reconnect to them later. Alternatively, the same can be done with tmux.
$ screen -S urbit
urbit directory:
$ ./<ship_dir_name>/.run -p 32123
control-a d$ screen -r
A lot of the above documentation comes from combining existing resources from Digital Ocean and Urbit into a single guide. The main piece here that I had to figure out myself was the specific Nginx config required to get Urbit to work properly.
Nginx is also pretty powerful and configurable. You can do things like have your urbit on an existing server under a subdomain. That kind of thing is left as an exercise for the reader.
On iOS you can save a website to your homescreen as an icon. If you do this for your urbit domain it's a little like having it as an app.