File tree 3 files changed +44
-10
lines changed
3 files changed +44
-10
lines changed Original file line number Diff line number Diff line change 1
- FROM centurylink/openssl as keys
1
+ FROM nginx:alpine
2
+ RUN apk add --no-cache openssl
2
3
RUN echo $'[req] \n \
3
4
distinguished_name = req_distinguished_name \n \
4
5
x509_extensions = v3_req \n \
@@ -12,9 +13,9 @@ subjectAltName = @alt_names \n\
12
13
[alt_names] \n \
13
14
DNS.1 = *.localhost \n \
14
15
DNS.2 = localhost' > openssl.cnf
15
- RUN openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -keyout cert.key -out cert.crt -config openssl.cnf
16
-
17
- FROM nginx:alpine
16
+ RUN mkdir -p /run/secrets/
17
+ RUN openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -keyout /run/secrets/cert.key -out /run/secrets/cert.crt -config openssl.cnf
18
18
COPY . /etc/nginx/
19
- COPY --from=keys cert.key /run/secrets/cert.key
20
- COPY --from=keys cert.crt /run/secrets/cert.crt
19
+ RUN ln -sf /dev/stdout /var/log/nginx/bots.access.log
20
+ RUN rm openssl.cnf
21
+ RUN apk del openssl
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ Awesome Nginx configuration template and a set of handy must-have snippets.
14
14
* Various predefined locations
15
15
* Advanced logging
16
16
* SEO
17
- * Docker- ready
17
+ * Docker/Swarm ready
18
18
19
19
## Requirements
20
- * Docker
21
- * docker-compose
20
+ * ` Docker ` >= ` 1.13 `
21
+ * ` docker-compose ` >= ` 3.1 `
22
22
23
23
Configs themselves depend on ` Nginx ` >= ` 1.9.5 ` , if used separately.
24
24
@@ -52,10 +52,43 @@ $ docker-compose exec nginx nginx -s reload
52
52
### Logs
53
53
By default a new ` logs/ ` directory should be created in the project directory, that directly maps to the nginx logs directory.
54
54
55
+ #### Docker swarm
56
+ To run in Docker swarm first make sure your Docker setup is in swarm mode:
57
+
58
+ ``` bash
59
+ $ docker swarm init
60
+ ```
61
+
62
+ First of all you need to define your domain ssl certificate and key as a swarm secret:
63
+
64
+ ``` bash
65
+ $ docker secret create cert.crt your_certificate.crt
66
+ $ docker secret create cert.key your_certificate_key.key
67
+ ```
68
+
69
+ Now to start or update nginx (and php) services in the swarm run:
70
+
71
+ ``` bash
72
+ $ docker stack deploy -c docker-compose.yml --with-registry-auth --prune app
73
+ ```
74
+
75
+ To see nginx logs run:
76
+ ``` bash
77
+ $ docker service logs -f app_nginx
78
+ ```
79
+
80
+ To scale services:
81
+ ``` bash
82
+ $ docker service scale app_nginx=2 app_fpm=10
83
+ ```
84
+
85
+ Now you can refresh the page a couple of times and notice different host names that your requests land on.
55
86
56
87
### Customization
57
88
58
89
The main virtual host definition is located at ` servers/main.conf ` .
90
+ Probably the best way to work with the repo is by cloning it and hooking up docker hub to automatically build a new image whenever there's new code.
91
+
59
92
60
93
## If something doesn't work
61
94
* Check error and access logs
Original file line number Diff line number Diff line change 1
1
version : ' 3.1'
2
2
services :
3
3
nginx :
4
- hostname : ${HOST_NAME:- localhost}
4
+ hostname : localhost
5
5
image : umkus/nginx-boilerplate
6
6
ports :
7
7
- 80:80
You can’t perform that action at this time.
0 commit comments