-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.spec
272 lines (236 loc) · 8.45 KB
/
nginx.spec
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
%global _disable_ld_no_undefined 1
%define nginx_home /var/lib/nginx
%define nginx_home_tmp %{nginx_home}/tmp
%define nginx_logdir /var/log/nginx
%define nginx_confdir %{_sysconfdir}/nginx
%define nginx_modulesdir %{_libdir}/nginx
%define nginx_datadir %{_datadir}/nginx
%define nginx_webroot /srv/www/html
%global optflags %{optflags} -Ofast
Summary: Robust, small and high performance HTTP and reverse proxy server
Name: nginx
Version: 1.27.3
Release: 1
Group: System/Servers
# BSD License (two clause)
# http://www.freebsd.org/copyright/freebsd-license.html
License: BSD
Url: https://nginx.net/
Source0: http://nginx.org/download/%{name}-%{version}.tar.gz
Source1: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/refs/tags/v1.2.2-r1.tar.gz
Source51: nginx.service
Source52: nginx.logrotate
Source53: ssl.conf
Source54: nginx.conf
Source55: default.conf
Source100: index.html
Source101: poweredby.png
Source102: nginx-logo.png
Source103: 50x.html
Source104: 404.html
BuildRequires: gd-devel
BuildRequires: GeoIP-devel
BuildRequires: perl-devel
BuildRequires: perl(ExtUtils::Embed)
BuildRequires: pkgconfig(libpcre)
BuildRequires: pkgconfig(libxslt)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(zlib)
BuildRequires: systemd-macros
# For _create_ssl_certificate macro
BuildRequires: rpm-helper
Requires(post): rpm-helper
Requires: pcre
Requires: openssl
Provides: webserver
Requires: www-user
Requires(pre): www-user
%systemd_requires
# As of 1.25.0, the quic patches are merged and the separate quic
# branch packages are obsolete.
%rename nginx-quic
%description
Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3
proxy server written by Igor Sysoev.
%package mod-http-perl
Summary: Nginx HTTP perl module
Group: System/Servers
Requires: %{name} = %{EVRD}
%rename nginx-quic-mod-http-perl
%description mod-http-perl
%{summary}.
%package mod-http-geoip
Summary: Nginx HTTP geoip module
Group: System/Servers
Requires: %{name} = %{EVRD}
Requires: geoip
%rename nginx-quic-mod-http-geoip
%description mod-http-geoip
%{summary}.
%package mod-http-image-filter
Summary: Nginx HTTP image filter module
Requires: %{name} = %{EVRD}
%rename nginx-quic-mod-http-image-filter
%description mod-http-image-filter
%{summary}.
%prep
%autosetup -p1 -a1
%build
%serverbuild_hardened
%set_build_flags
./configure \
--user=www \
--group=www \
--prefix=%{nginx_datadir} \
--sbin-path=%{_sbindir}/nginx \
--conf-path=%{nginx_confdir}/nginx.conf \
--error-log-path=%{nginx_logdir}/error.log \
--http-log-path=%{nginx_logdir}/access.log \
--http-client-body-temp-path=%{nginx_home_tmp}/client_body \
--http-proxy-temp-path=%{nginx_home_tmp}/proxy \
--http-fastcgi-temp-path=%{nginx_home_tmp}/fastcgi \
--pid-path=/run/nginx.pid \
--lock-path=/var/lock/subsys/nginx \
--modules-path=%{nginx_modulesdir} \
--add-module=nginx-rtmp-module-* \
--with-file-aio \
--with-ipv6 \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-http_slice_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_perl_module=dynamic \
--with-mail \
--with-mail_ssl_module \
--with-pcre \
--with-pcre-jit \
--with-ld-opt="%{build_ldflags} -Wl,-E" # so the perl module finds its symbols
sed -i -e 's|-Wl,--no-undefined||g' objs/Makefile
# this is only passed to perl module being built and only overrides the
# default '-O' flag which anyways lowers optimizations (which we don't
# want)
%make_build OPTIMIZE="-fno-PIE"
%install
%make_install INSTALLDIRS=vendor
find %{buildroot} -type f -name .packlist -exec rm -f {} \;
find %{buildroot} -type f -name perllocal.pod -exec rm -f {} \;
find %{buildroot} -type f -empty -exec rm -f {} \;
find %{buildroot} -type f -exec chmod 0644 {} \;
find %{buildroot} -type f -name '*.so' -exec chmod 0755 {} \;
chmod 0755 %{buildroot}%{_sbindir}/nginx
# Get rid of broken upstream config samples
rm -rf %{buildroot}%{nginx_confdir}/conf.d
# And install our own configs...
install -p -D -m 0644 %{S:51} %{buildroot}%{_unitdir}/nginx.service
install -p -D -m 0644 %{S:52} %{buildroot}%{_sysconfdir}/logrotate.d/nginx
install -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d
install -p -m 0644 %{S:53} %{buildroot}%{nginx_confdir}/
install -p -D -m 0644 %{S:54} %{buildroot}%{nginx_confdir}/
install -p -D -m 0644 %{S:54} %{buildroot}%{nginx_confdir}/nginx.conf.default
install -p -d -m 0755 %{buildroot}%{nginx_home_tmp}
install -p -d -m 0755 %{buildroot}%{nginx_logdir}
install -p -d -m 0755 %{buildroot}%{nginx_webroot}
install -p -d -m 0755 %{buildroot}%{nginx_modulesdir}
install -p -d -m 0755 %{buildroot}%{nginx_datadir}/modules
mkdir -p %{buildroot}%{nginx_confdir}/sites-available %{buildroot}%{nginx_confdir}/sites-enabled
install -p -D -m 0644 %{S:55} %{buildroot}%{nginx_confdir}/sites-available/default.conf
ln -s ../sites-available/default.conf %{buildroot}%{nginx_confdir}/sites-enabled/
mkdir -p %{buildroot}%{nginx_confdir}/http.conf.d
install -p -m 0644 %{S:100} %{S:101} %{S:102} %{S:103} %{S:104} %{buildroot}%{nginx_webroot}
# add current version
sed -i -e "s|_VERSION_|%{version}|g" %{buildroot}%{nginx_webroot}/index.html
install -d %{buildroot}%{_mandir}/man8
install -m0644 man/*.8 %{buildroot}%{_mandir}/man8/
echo 'load_module "%{nginx_modulesdir}/ngx_http_perl_module.so";' > %{buildroot}%{nginx_datadir}/modules/mod-http-perl.conf
echo 'load_module "%{nginx_modulesdir}/ngx_http_geoip_module.so";' > %{buildroot}%{nginx_datadir}/modules/mod-http-geoip.conf
echo 'load_module "%{nginx_modulesdir}/ngx_http_image_filter_module.so";' > %{buildroot}%{nginx_datadir}/modules//mod-http-image-filter.conf
install -d %{buildroot}%{_presetdir}
cat > %{buildroot}%{_presetdir}/86-nginx.preset << EOF
enable nginx.service
EOF
%post
%systemd_post nginx.service
%_create_ssl_certificate nginx
%preun
%systemd_preun nginx.service
%postun
%systemd_postun nginx.service
%post mod-http-geoip
if [ $1 -eq 1 ]; then
systemctl reload nginx.service >/dev/null 2>&1 || :
fi
%post mod-http-perl
if [ $1 -eq 1 ]; then
systemctl reload nginx.service >/dev/null 2>&1 || :
fi
%post mod-http-image-filter
if [ $1 -eq 1 ]; then
systemctl reload nginx.service >/dev/null 2>&1 || :
fi
%files
%doc LICENSE CHANGES
%dir %{nginx_datadir}
%dir %{nginx_datadir}/modules
%dir %{nginx_modulesdir}
%{_sbindir}/nginx
%{_mandir}/man3/nginx.3pm*
%{_mandir}/man8/*
%{_presetdir}/86-nginx.preset
%{_unitdir}/nginx.service
%{nginx_datadir}/html/*.html
/srv/www/html/*.html
/srv/www/html/*.png
%dir %{nginx_confdir}
%dir %{nginx_confdir}/conf.d
%dir %{nginx_confdir}/http.conf.d
%config(noreplace) %{nginx_confdir}/win-utf
%config(noreplace) %{nginx_confdir}/nginx.conf.default
%config(noreplace) %{nginx_confdir}/scgi_params
%config(noreplace) %{nginx_confdir}/scgi_params.default
%config(noreplace) %{nginx_confdir}/fastcgi.conf
%config %{nginx_confdir}/fastcgi.conf.default
%config %{nginx_confdir}/mime.types.default
%config(noreplace) %{nginx_confdir}/fastcgi_params
%config %{nginx_confdir}/fastcgi_params.default
%config(noreplace) %{nginx_confdir}/koi-win
%config(noreplace) %{nginx_confdir}/koi-utf
%config(noreplace) %{nginx_confdir}/nginx.conf
%config(noreplace) %{nginx_confdir}/mime.types
%config(noreplace) %{nginx_confdir}/ssl.conf
%dir %{nginx_confdir}/sites-available
%config(noreplace) %{nginx_confdir}/sites-available/default.conf
%dir %{nginx_confdir}/sites-enabled
%config(noreplace) %{nginx_confdir}/sites-enabled/default.conf
%config(noreplace) %{nginx_confdir}/uwsgi_params
%config(noreplace) %{nginx_confdir}/uwsgi_params.default
%config(noreplace) %{_sysconfdir}/logrotate.d/nginx
%attr(-,www,www) %dir %{nginx_home}
%attr(-,www,www) %dir %{nginx_home_tmp}
%attr(-,www,www) %dir %{nginx_logdir}
%files mod-http-perl
%{nginx_datadir}/modules/mod-http-perl.conf
%{nginx_modulesdir}/ngx_http_perl_module.so
%dir %{perl_vendorarch}/auto/nginx
%{perl_vendorarch}/nginx.pm
%{perl_vendorarch}/auto/nginx/nginx.so
%files mod-http-geoip
%{nginx_datadir}/modules/mod-http-geoip.conf
%{nginx_modulesdir}/ngx_http_geoip_module.so
%files mod-http-image-filter
%{nginx_datadir}/modules/mod-http-image-filter.conf
%{nginx_modulesdir}/ngx_http_image_filter_module.so