Letsencrypt Tutorial
Introduction
At some point you probably want to access your opentrigger setup from outside your firewall. This tutorial will guide you how to setup password protection and encrypt your traffic with Letsencrypt. Please be aware that security is always an investment, and there is no such thing as absolute security. Blindly following this tutorial alone will not protect your data.
Forwarding ports on your firewall and setting up domain names is a very specific task we can not cover in this tutorial. Your Router/Firewall/... usually comes with documentation which should cover the former. Another source of information would be: portforward.com (only read the articles, they also want to sell you software which does it for you - but do you really want to thrust that?). If you need a free subdomain with dyndns service have a look at: freedns.afraid.org
Requirements
For this tutorial we assume that you are running Raspbian jessie, your opentrigger stack ist already set up and you have a domain name configured.
Your domain name resolution has to work from outside (the public internet) and on your local network. The TCP Ports 80 and 443 must be mapped to your device - nothing more, nothing less. Keep away form that DMZ or ExposedHost settings. We will use letutorial.dev.opentrigger.com
as domain for this tutorial, please replace that with your hostname.
Installing required Packages
nginx
is a resource friendly, but fully featured webserver.
apache2-utils
contain the htpasswd
tool we will use to add basic authentication.
haveged
helps with entropy problems, its not a hard requirement, but will speed things up a bit.
After that nginx is running on port 80 and if you navigate to http://letutorial.dev.opentrigger.com/
you should see the nginx default page.
We also need certbot
which currently is the recomendet way of getting Letsencrypt certificates.
Certificates
Now we start certbot-auto
which will download and install its dependencies and performs (self)updates when needed. So the first run will take a little longer.
Some dialogs will pop up and asking you to provide an Email address and agree to the 'Terms of Service'.
After the procedure is complete, certbot will tell you where your new certificates are stored:
Configuring nginx
Generating dhparams, even with havegd
running, this could take some time.
If you don't want to wait you could start another terminal session and leave that running in the background. (or use your shell to make that happen).
Setup your credentials. Substitute <username>
with your preferred username.
You will be asked for the password (twice). Please refer to man htpasswd
on how to manage users.
Create a new site configuration file.
Paste the following content.
Testing
Check if openssl dhparam
is finished by now, if not you have to wait for it.
Enable the site.
Now you should be able to access your device over a password protected and encrypted Link:
Now go to
and run the test. You should not go for less than A:
Renewal
Your certificate is valid for 90 days, but renewal is easy:
It would be best to automate the renewal process, please consult certbot's documentation for that.
Last updated