1- # Step-by-Step Setup Instructions for Let's Encrypt
1+ ![ letsencrypt-760x320 ] ( https://cloud.githubusercontent.com/assets/194400/23311312/8c4cc85a-faad-11e6-912c-9cc96ec21da6.png )
22
3- > Note: These instructions are only applicable to web apps
4- with a custom domain name.
3+ # Step-by-Step Setup Instructions for Let's Encrypt _ Free_ SSL
4+
5+ > _ Note: These instructions are only applicable to web apps
6+ with a ** custom domain** name_ .
57
68
79## Why?
@@ -12,13 +14,71 @@ to Secure/Encrypt all communications between users and your app.
1214
1315## What?
1416
15- Let's Encrypt offers a *** Free*** Automated SLL Certificate Service
16-
17+ Let's Encrypt offers a *** Free*** _ Automated_ SSL Certificate Service
18+ brought to you by the ** _ non-profit_
19+ Internet Security Research Group** (ISRG).
1720see: https://letsencrypt.org/about/
1821
22+ ### Instructions Valid for Apps Written in _ Any_ Language/Framework!
23+
24+ The instructions in this tutorial/guide are applicable
25+ to an app written in *** any language or framework*** .
26+ You will _ temporarily_ deploy a Node.js ` http-server ` to your Heroku app
27+ which will allow Let's Encrypt to _ verify_ that you "_ own_ " the app/domain.
28+
29+ > _ ** Note** : No Node.js knowledge is assumed or required. You won't be
30+ writing a single line of JS code._
31+
32+ Once you have set up SSL you can deploy what ever kind of app you like.
33+ (_ in our case the app is written in [ Elixir/Phoenix!] ( https://github.com/dwyl/technology-stack/#the-pete-stack ) ...
34+ node.js is just an easy way to get this working in a ** generic** way._ )
35+
1936## How?
2037
21- ### Step 1: Install ` certbot `
38+ "** certbot** " is the script that _ automates_ the certificate creation process.
39+
40+ ### Step 1: Clone this Repository to get the Setup Code
41+
42+ ```
43+ git clone https://github.com/dwyl/learn-heroku.git
44+ cd learn-heroku
45+ ```
46+
47+ ### Step 2: Set Git Remote
48+
49+ Check what your _ current_ ` origin ` remote is:
50+ ``` sh
51+ git remote -v
52+ ```
53+ ![ git-remote] ( https://cloud.githubusercontent.com/assets/194400/23321003/400c1fa4-fad5-11e6-8e9b-0caf85963dd1.png )
54+
55+ Set it to what ever the git url is for the app you are setting up SSL for. e.g:
56+ ``` sh
57+ git remote set-url origin git@github.com:healthlocker/healthlocker.git
58+ ```
59+
60+ Push your current branch to the GitHub repo:
61+ ``` sh
62+ git push --set-upstream origin letsencrypt-temporary-server
63+ ```
64+
65+ ### Step 3: _ Temporarily_ Change the Branch Heroku Deploys from
66+
67+ ![ ssl1] ( https://cloud.githubusercontent.com/assets/194400/23256626/22f87da4-f9b8-11e6-96d1-72e50ebeffa4.png )
68+
69+ Change it to the name of your branch e.g:
70+
71+ ![ ssl2] ( https://cloud.githubusercontent.com/assets/194400/23256625/22f75cee-f9b8-11e6-896f-296e353429be.png )
72+
73+ It should look something like this:
74+
75+ ![ ssl-deploy-from-diff-branch-disable-ci-check] ( https://cloud.githubusercontent.com/assets/194400/23256955/7e62225c-f9b9-11e6-9ba0-74e5d2644f8a.png )
76+ remember to (_ temporarily_ ) _ dissable_ the checkbox `Wait for CI to
77+ pass before deploy` <br />
78+ (_ we have no tests for this temporary server!_ ).
79+
80+
81+ ### Step 4: Install ` certbot `
2282
2383> ` certbot ` installation instructions for various platforms:
2484https://letsencrypt.org/getting-started
@@ -28,30 +88,37 @@ brew install certbot
2888```
2989![ bew-install-certbot] ( https://cloud.githubusercontent.com/assets/194400/23254553/59f014a0-f9b0-11e6-9667-4e5e9b8014bc.png )
3090
31- (_ might take a few minutes to install on a slower internet connection...
91+ (_ it might take a few minutes to install on a slower internet connection...
3292 be patient..._ )
3393
34- ### Step 2 : Run ` certbot ` Command (_ Manual Setup_ )
94+ ### Step 4 : Run ` certbot ` Command (_ Manual Setup_ )
3595
3696Once you've installed ` certbot ` run the following command:
3797``` sh
3898sudo certbot certonly --manual
3999```
40100
41- Top-tip you will want to use both the domain an ` www ` subdomain:
101+ Remember to use both the domain a ` www ` subdomain. ( _ separated by a space _ ) e.g :
42102
103+ ```
104+ example.com www.example.com
105+ ```
106+
107+ Our app was:
43108```
44109healthlocker.uk www.healthlocker.uk
45110```
46111
47112Follow the steps and ** pay _ close_ attention** !
48113
49- Enter the
50-
51114When you reach the screen that looks like this:
115+
52116![ certbot-instructions] ( https://cloud.githubusercontent.com/assets/194400/23255249/c7d2b250-f9b2-11e6-9d45-d2cdb965defa.png )
53117
54- Instructions: (_ for reference ONLY see below for modified instructions_ )
118+ _ ** DON'T** ` continue ` until you have completed ** Step 5** _ .
119+
120+ Instructions printed by ` certbot ` :
121+ (_ for reference ONLY see below for sub-set of instructions_ )
55122```
56123mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
57124cd /tmp/certbot/public_html
@@ -64,62 +131,47 @@ s = BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandle
64131s.serve_forever()"
65132```
66133
67- You _ wont_ be _ able_ to run shell commands on the Heroku instance
134+ You _ wont_ be _ able_ to run shell commands on a Heroku instance
68135so we need to use a _ temporary_ node.js server to achieve our objective.
69136
70137In your ` current working directory ` (_ on your localhost_ )
71138run the following command to create the ` .well-known/acme-challenge ` directory:
72139
140+ #### Step 4.1 Create the ` .well-known/acme-challenge ` Directory (_ if it doesn't exist_ )
141+
73142```
74143mkdir -p .well-known/acme-challenge
75144```
76145
146+ #### Step 4.2 Create a File for the Token Verification
147+
77148Now *** copy-paste*** the ` printf ` command from the ` certbot ` instructions:
78149they should look _ something_ like this:
79150
80151```
81152printf "%s" WgFpodyij_PDzkU0MZ3CzKCI05hjLOcq2tP-1rs6ko0.kURQ5HbILtRXEwJA2QI4W5TdBkjnZNqH2_RHORvmN6w > .well-known/acme-challenge/WgFpodyij_PDzkU0MZ3CzKCI05hjLOcq2tP-1rs6ko0
82153```
83154The tokens will be _ specific_ to you so make sure you get the correct tokens.
155+ (_ there is one token per domain_ )
84156
85- ### Step 3: Set Git Remote
157+ #### Step 4. 3: Commit Your Changes ( _ the token file _ ) and Push to GitHub
86158
87- Check what your _ current_ ` origin ` remote is:
88- ``` sh
89- git remote -v
90- ```
91- ![ git-remote] ( https://cloud.githubusercontent.com/assets/194400/23256452/7318d01e-f9b7-11e6-94cb-d5450d1addea.png )
159+ Make a commit on your local branch so you can push to github
160+ (_ and trigger the heroku build_ )
92161
93- Set it to what ever the git url is for the app you are setting up SSL for. e.g:
94- ``` sh
95- git remote set-url origin git@github.com:healthlocker/healthlocker.git
96162```
97-
98- Push your current branch to the GitHub repo:
99- ``` sh
100- git push --set-upstream origin letsencrypt-temporary-server
163+ git add .
164+ git commit -m 'add letsencrypt verification file'
165+ git push
101166```
167+ That will deploy the file you created in Step 4.2 to Heroku.
102168
103- ### Step 4: _ Temporarily_ Change the Branch Heroku Deploys from
104-
105- ![ ssl1] ( https://cloud.githubusercontent.com/assets/194400/23256626/22f87da4-f9b8-11e6-96d1-72e50ebeffa4.png )
106-
107- Change it to the name of your branch e.g:
108-
109- ![ ssl2] ( https://cloud.githubusercontent.com/assets/194400/23256625/22f75cee-f9b8-11e6-896f-296e353429be.png )
110-
111- It should look something like this:
169+ ### Step 5: Visit the Endpoint in your Browser to _ Confirm_ it _ Worked_ :
112170
113- ![ ssl-deploy-from-diff-branch-disable-ci-check] ( https://cloud.githubusercontent.com/assets/194400/23256955/7e62225c-f9b9-11e6-9ba0-74e5d2644f8a.png )
114- remember to (_ temporarily_ ) _ dissable_ the checkbox `Wait for CI to
115- pass before deploy` (_ we have no tests for this temporary server!_ ).
171+ Visit your app in a web browser to confirm the deploy worked.
172+ e.g: http://example.com/.well-known/acme-challenge
116173
117- make a commit on your local branch so you can push to github (_ and trigger the heroku build_ )
118-
119-
120- ### Step 5: Visit the Endpoint in your Browser to confirm it worked:
121-
122- our is: http://healthlocker.uk/.well-known/acme-challenge/
174+ The url for _ our_ app was: http://healthlocker.uk/.well-known/acme-challenge
123175
124176![ click-on-filename-to-test] ( https://cloud.githubusercontent.com/assets/194400/23293421/eda79e68-fa5d-11e6-95d4-a8c57fe4a8fd.png )
125177
@@ -222,9 +274,15 @@ Restore the `default` branch for deployment on Heroku:
222274<br /> <br /><br /> <br />
223275
224276
225- ## Trouble-Shooting
277+ # Trouble-Shooting (_ if it doesn't work!_ )
278+
279+ The _ first_ time I tried to run the ` certbot ` command, _ nothing_ worked!
280+ E.g: the Build failed on Heroku, the cert process failed (_ see below_ ).
281+ This is a catalog of the Trouble-Shooting we did.
226282
227- The _ first_ time I tried this the build *** failed*** :
283+ > _ As always, if you get stuck,
284+ [ ** ask a question** ] ( https://github.com/dwyl/learn-heroku/issues )
285+ we will try our best to help!_
228286
229287![ heroku-activity-log-fail] ( https://cloud.githubusercontent.com/assets/194400/23256822/026ec3a8-f9b9-11e6-9c4b-c26af4276426.png )
230288
@@ -272,7 +330,11 @@ I deleted all the files created in the process and started from scratch ...
272330Failed again: <br />
273331![ fail again] ( https://cloud.githubusercontent.com/assets/194400/23263831/4c5070d4-f9d7-11e6-8559-57b2aa714b26.png )
274332
275- Just keep trying ...
333+ Re-trace your steps and make sure you followed the instructions _ exactly_ .
334+ Also, timing matters. if you take a break between steps
335+ you will get a "Time Out Error"...
336+ We initially got it wrong,
337+ but after re-running the command it works as expected.
276338
277339
278340#### If you get a _ Certificate Warning_ in Step 7.8
@@ -302,6 +364,10 @@ After running `certbot` _another_ time, it worked. :rocket:
302364
303365## Background Reading
304366
367+ + An introduction to SSL certificates:
368+ https://woocommerce.com/2015/12/ssl-certificates-for-ecommerce
369+ + Public Key Certificate: https://en.wikipedia.org/wiki/Public_key_certificate
370+ + Transport Layer Security: https://en.wikipedia.org/wiki/Transport_Layer_Security
305371+ Certbot Manual mode: https://certbot.eff.org/docs/using.html#manual
306372+ Inspiration tutorial (_ Ruby-on-Rails focussed_ ):
307373https://collectiveidea.com/blog/archives/2016/01/12/lets-encrypt-with-a-rails-app-on-heroku
0 commit comments