Skip to content

Commit a088dfc

Browse files
Update README
1 parent 584c8d7 commit a088dfc

File tree

1 file changed

+64
-38
lines changed

1 file changed

+64
-38
lines changed

README.md

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# docker-nginx-certbot
2+
23
Create and automatically renew website SSL certificates using the Let's Encrypt
34
free certificate authority and its client *certbot*. Built on top of the Nginx
45
server running on Debian. OpenSSL is used to create the Diffie-Hellman
56
parameters used during the initial handshake.
67

8+
9+
710
# Acknowledgments and Thanks
811

912
This container requests SSL certificates from
@@ -21,6 +24,8 @@ certificates (i.e. both `example.com` and `www.example.com` will be included in
2124
the same certificate request if they are defined in the Nginx configuration
2225
files).
2326

27+
28+
2429
# Usage
2530

2631
## Before you start
@@ -41,12 +46,13 @@ files).
4146
clear that this is a Dockerfile which requires
4247
[Docker](https://www.docker.com/) to function.
4348

49+
4450
## Run with `docker run`
4551

4652
### Build it yourself
4753
This option is for if you have downloaded this entire repository.
4854

49-
Place any additional server configuration you desire inside the `nginx_confd/`
55+
Place any additional server configuration you desire inside the `nginx_conf.d/`
5056
folder and run the following command in your terminal while residing inside
5157
the `src/` folder.
5258
```bash
@@ -69,23 +75,23 @@ Don't forget to build it!
6975
docker build --tag jonasal/nginx-certbot:latest .
7076
```
7177

72-
### The run command
78+
### The `run` command
7379
Irregardless what option you chose above you run it with the following command:
7480
```bash
7581
docker run -it --env [email protected] -p 80:80 -p 443:443 \
7682
-v nginx_secrets:/etc/letsencrypt jonasal/nginx-certbot:latest
7783
```
78-
The `CERTBOT_EMAIL` environment variable is required by certbot for them to
79-
contact you in case of security issues.
84+
The `CERTBOT_EMAIL` environment variable is required by Let's Encrypt, so they
85+
can contact you in case of security issues.
8086

8187
> You should be able to detach from the container by pressing
82-
`Ctrl`+`p`+`Ctrl`+`o`
88+
`Ctrl`+`p`+`Ctrl`+`o`
8389

84-
## Run with `docker-compose`
8590

91+
## Run with `docker-compose`
8692
An example of a `docker-compose.yaml` file can be found in the `example` folder.
8793
The default parameters that are found inside the `.env` file will be overwritten
88-
any environment variables you set in the `.yaml` file.
94+
by any environment variables you set in the `.yaml` file.
8995
```yaml
9096
version: '3'
9197
services:
@@ -108,18 +114,20 @@ volumes:
108114
```
109115
110116
You then build and start with the following commands. Just remember to
111-
place any additional server configs you want inside the `nginx_confd/` folder
117+
place any additional server configs you want inside the `nginx_conf.d/` folder
112118
beforehand.
113119

114120
```bash
115121
docker-compose up --build
116122
```
117123

124+
125+
118126
# Good to Know
119127

120128
### Initial testing
121129
In case you are experimenting with setting this up I suggest you set the
122-
environment variable `STAGING=1` as this will change the challenge URL to
130+
environment variable `STAGING=1`, since this will change the challenge URL to
123131
the staging one. This will not give you *proper* certificates, but it has
124132
ridiculous high
125133
[rate limits](https://letsencrypt.org/docs/staging-environment/) compared to
@@ -133,29 +141,32 @@ docker run -d --env [email protected] --env STAGING=1 \
133141
```
134142

135143
### Creating a server .conf file
136-
137144
As an example of a barebone (but functional) SSL server in Nginx you can
138-
look at the file `example_server.conf` inside the `example` directory. By
145+
look at the file `example_server.conf` inside the `example/` directory. By
139146
replacing '`yourdomain.org`' with your own domain you can actually use this
140147
config to quickly test if things are working properly.
141148

142-
Place the modified config inside `nginx_confd/`, `build` the container and then
143-
run it as described [above
144-
](https://github.com/JonasAlfredsson/docker-nginx-certbot/#usage). Let it do
145-
it's magic for a while, and then try to visit your domain. You should be greeted
146-
with the string `Let's Encrypt certificate successfully installed!`
149+
Place the modified config inside the `nginx_conf.d/` folder, `build` the
150+
container and then run it as described
151+
[above](https://github.com/JonasAlfredsson/docker-nginx-certbot/#usage). Let
152+
the container do it's magic for a while, and then try to visit your domain. You
153+
should now be greeted with the string
154+
"`Let's Encrypt certificate successfully installed!`".
147155

148156
### How the script add domain names to certificate requests
157+
The included scripts will go trough all configuration files (`*.conf*`) it
158+
finds inside Nginx's `/etc/nginx/conf.d/` folder, and create requests from the
159+
file's content. In every unique file it will find any line that says:
149160

150-
The script will go trough all configuration files it finds inside Nginx's
151-
`conf.d` folder, and create requests from the file's content. In every unique
152-
file it will find the line that says
153161
```
154162
ssl_certificate_key /etc/letsencrypt/live/yourdomain.org/privkey.pem;
155163
```
156-
which means that the "primary domain" is `yourdomain.org`. It will then find all
157-
the lines that contain `server_name` and make a list of all the words that exist
158-
on the same line. So a file containing something like this:
164+
165+
and only extract the part which here says "`yourdomain.org`", and this will
166+
henceforth be used as the "primary domain" for this config file. It will then
167+
find all the lines that contain `server_name` and make a list of all the domain
168+
that exist on the same line. So a file containing something like this:
169+
159170
```
160171
server {
161172
listen 443 ssl;
@@ -166,49 +177,64 @@ server {
166177
167178
server {
168179
listen 443 ssl;
169-
server_name yourdomain.org sub.yourdomain.org;
180+
server_name sub.yourdomain.org www.yourdomain.org;
170181
ssl_certificate_key /etc/letsencrypt/live/yourdomain.org/privkey.pem;
171182
...
172183
}
173184
```
174-
will share the same certificate, but the certbot command will include all
175-
listed domain variants. The limitation is that you should list all your
176-
listening servers that have the same primary domain in the same file. The
177-
certificate request from the above file will then become something like this:
185+
186+
will share the same certificate file, but the certbot command will include all
187+
listed domain variants. The limitation is that you should write all your
188+
server blocks that have the same primary domain in the same file. The
189+
certificate request from the above file will then become something like this
190+
(duplicates will be removed):
191+
178192
```
179193
certbot ... -d yourdomain.org -d www.yourdomain.org -d sub.yourdomain.org
180194
```
181195

182196
### Diffie-Hellman parameters
183-
184197
Regarding the Diffie-Hellman parameter it is recommended that you have one for
185198
your server. However, you can make a config file without it and Nginx will work
186-
fine with ciphers that don't rely on Diffie-Hellman key exchange.
187-
([Info about
188-
ciphers](https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html)).
199+
fine with ciphers that don't rely on the Diffie-Hellman key exchange
200+
([more info about ciphers](https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html)).
189201

190202
The larger you make these parameters the longer it will take to generate them.
191203
I was unlucky and it took me 65 minutes to generate a 4096 bit parameter on an
192204
old 3.0GHz CPU. This will vary greatly between runs as some randomness is
193205
involved. A 2048 bit parameter, which is still secure today, can probably be
194-
calculated in about 3-5 minutes on a modern CPU. To modify the size of the
195-
parameter you may set the `DHPARAM_SIZE` environment variable. Default is `2048`
196-
if nothing is provided.
206+
calculated in about 1-3 minutes on a modern CPU (this process will only have to
207+
be done once). To modify the size of the parameter you may set the
208+
`DHPARAM_SIZE` environment variable. Default is `2048` if nothing is provided.
197209

198210
It is also possible to have all your server configs point to the same
199211
Diffie-Hellman parameter on disk. There is no negative effects in doing this for
200212
home use
201213
[[1](https://security.stackexchange.com/questions/70831/does-dh-parameter-file-need-to-be-unique-per-private-key)]
202214
[[2](https://security.stackexchange.com/questions/94390/whats-the-purpose-of-dh-parameters)].
203215
For persistence you should place it inside the dedicated
204-
folder `/etc/letsencrypt/dhparams/` which is inside a Docker volume. There is
216+
folder `/etc/letsencrypt/dhparams/`, which is inside a Docker volume. There is
205217
however no requirement to do so, as a missing parameter will be created where
206-
the config file expects the file to be. This means that you may also create this
207-
file on an external computer and mount it to any folder that is not under
208-
`/etc/letsencrypt/` as that will cause a double mount.
218+
the config file expects the file to be.
219+
220+
You can also create this file on a completely different (faster?) computer and
221+
just mount the created file into this container. This is perfectly fine, but use
222+
a folder that is not under `/etc/letsencrypt/`, since that would cause a double
223+
mount.
224+
225+
209226

210227
# Changelog
211228

229+
### 0.12
230+
- Added `--cert-name` flag to certificate request.
231+
- This allows both adding and subtracting domains to the same certificate.
232+
- Makes it possible to have path names that are not domain names (but this
233+
is not allowed yet)
234+
- Made the file parsing functions smarter to only find unique file paths.
235+
- Cleaned up some log output.
236+
- Updated the `docker-compose` example.
237+
212238
### 0.11
213239
- Python 2 is EOL, so it's time to move over to Python 3.
214240
- From now on DockerHub will also build with tags (`jonasal/nginx-certbot:0.11`)

0 commit comments

Comments
 (0)