blob: 8b69030e1d5a6a210cf56a69b748f038f8685d8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
---
# Target: alpine3.11
- name: Install Nginx and Certbot
hosts: nginx
vars:
user: nginx
home: "/etc/{{ user }}"
nginx_key: https://nginx.org/keys/nginx_signing.key
nginx_version: 1.16.1
nginx_headers_version: 552e216a0da95c685d9db4f43e209c3f2a803e49
brotli_version: e505dce68acc190cc5a1e780a3b0275e39f160ca
quiche_version: 3c75701c6fa5b29a9076d9f82251f5aeee2c7f79
tasks:
- name: Ensuring group exists
group:
name: "{{ user }}"
state: present
- name: Creating user and making home directory
user:
system: yes
state: present
name: "{{ user }}"
groups: "{{ user }}"
home: "{{ home }}"
- name: Installing the required nginx dependencies
apk:
state: present
update_cache: yes
name:
- gcc
- libc-dev
- make
- openssl-dev
- pcre-dev
- zlib-dev
- linux-headers
- curl
- gnupg
- libxslt-dev
- gd-dev
- geoip-dev
- perl-dev
- tar
- openssl
- name: Installing the required brotli dependencies
apk:
state: present
update_cache: yes
name:
- autoconf
- libtool
- automake
- git
- g++
- cmake
- go
- perl
- rust
- cargo
- name: Cloning repositories
git:
repo: "{{ item.repo }}"
dest: "{{ item.dest }}"
version: "{{ item.version }}"
with_items:
-
repo: https://github.com/google/ngx_brotli.git
dest: /opt/nginx/brotli
version: "{{ brotli_version }}"
-
repo: https://github.com/openresty/headers-more-nginx-module.git
dest: /opt/nginx/nginx-headers
version: "{{ nginx_headers_version }}"
-
repo: https://github.com/cloudflare/quiche
dest: /opt/nginx/quiche
version: "{{ quiche_version }}"
- name: Downloading nginx
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
with_items:
-
url: https://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
dest: /opt/nginx
-
url: https://nginx.org/download/nginx-{{ nginx_version }}.tar.gz.asc
dest: /opt/nginx
- name: Importing keys
shell: |
curl -sSL "{{ nginx_key }}" | gpg --import -
touch .nginx-key-imported
args:
chdir: /opt/nginx
creates: .nginx-key-imported
- name: Verifying application
shell: |
gpg --batch --verify nginx-{{ nginx_version }}-tar.gz nginx-{{ nginx_version }}.tar.gz.asc
touch .nginx-{{ nginx_version }}-verified
args:
chdir: /opt/nginx
creates: .nginx-{{ nginx_version }}-verified
- name: Extracting application source
unarchive:
src: /opt/nginx/nginx-{{ nginx_version}}.tar.gz
dest: /opt/nginx
remote_src: yes
- name: Building application
shell: >
export CONFIG="
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib/nginx/modules
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-http_auth_request_module
--with-http_xslt_module=dynamic
--with-http_image_filter_module=dynamic
--with-http_geoip_module=dynamic
--with-http_perl_module=dynamic
--with-threads
--with-stream
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-stream_realip_module
--with-stream_geoip_module=dynamic
--with-http_slice_module
--with-mail
--with-mail_ssl_module
--with-compat
--with-file-aio
--with-http_v2_module
--with-http_v3_module
--with-openssl=/opt/nginx/quiche/deps/boringssl
--with-quiche=/opt/nginx/quiche
--with-ipv6
--add-module=/opt/nginx/brotli
--add-module=/opt/nginx/nginx-headers
--with-cc-opt=-Wno-error"
&& patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch
&& ./configure $CONFIG
&& make -j$(getconf _NPROCESSORS_ONLN)
args:
chdir: /opt/nginx/nginx-{{ nginx_version }}
creates: objs/nginx
register: output
- debug: var=output
- name: Installing Application
shell: >
make install
&& mkdir -p /etc/nginx/default.d
&& mkdir -p /etc/nginx/conf.d
&& mkdir -p /etc/nginx/sites-available
&& mkdir -p /etc/nginx/sites-enabled
&& rm -rf /etc/nginx/*.default
&& rm -rf /etc/nginx/html
&& rm -rf /usr/sbin/nginx.old
&& strip /usr/sbin/nginx*
&& strip /usr/lib/nginx/modules/*.so
args:
chdir: /opt/nginx/nginx-{{ nginx_version }}
register: output
- debug: var=output
- name: Generating self signed certificate
shell: >
openssl req -x509 -newkey rsa:4096 -nodes -keyout nginx.key
-out nginx.crt -days 1095 -sha256 -subj '/CN=localhost'
args:
chdir: /etc/nginx
creates: nginx.crt
- name: Generating Diffie Hellman group
shell: openssl dhparam -out dhparam.pem 2048
args:
chdir: /etc/nginx
creates: dhparam.pem
|