2 # - /etc/sysconfig/nginx file
3 # - missing perl build/install requires
5 # Conditional build for nginx:
7 %bcond_with debug # enable debug logging: http://nginx.org/en/docs/debugging_log.html
8 %bcond_without threads # thread pool support
10 %bcond_without addition # http addition module
11 %bcond_without auth_request # auth_request module
12 %bcond_without dav # WebDAV
13 %bcond_without flv # http FLV module
14 %bcond_without gd # without http image filter module
15 %bcond_without geoip # without http geoip module and stream geoip module
16 %bcond_without http2 # HTTP/2 module
17 %bcond_without mail # don't build imap/mail proxy
18 %bcond_without perl # don't build with perl module
19 %bcond_without poll # poll module
20 %bcond_without realip # real ip (behind proxy)
21 %bcond_without select # select module
22 %bcond_without ssl # ssl support and http ssl module
23 %bcond_without stream # TCP/UDP proxy module
24 %bcond_without stub_status # http stub status module
25 %bcond_without sub # ngx_http_sub_module
26 %bcond_without xslt # without http xslt module
27 %bcond_with http_browser # http browser module (header "User-agent" parser)
28 %bcond_with modsecurity # modsecurity module
29 %bcond_with rtmp # rtmp support
30 %bcond_without vts # virtual host traffic status module
36 %define ssl_version 1.0.2
37 %define rtmp_version 1.2.1
38 %define vts_version 0.1.18
39 %define modsecurity_version 2.9.3
40 Summary: High perfomance HTTP and reverse proxy server
41 Summary(pl.UTF-8): Serwer HTTP i odwrotne proxy o wysokiej wydajności
43 # - stable: production quality with stable API
44 # - mainline: production quality but API can change
49 Group: Networking/Daemons/HTTP
50 Source0: http://nginx.org/download/%{name}-%{version}.tar.gz
51 # Source0-md5: 97207283f30cd90cdba638c3ea30323a
52 Source1: http://nginx.net/favicon.ico
53 # Source1-md5: 2aaf2115c752cbdbfb8a2f0b3c3189ab
55 Source3: %{name}.logrotate
57 Source6: %{name}.monitrc
59 Source14: %{name}.conf
60 Source17: %{name}-mime.types.sh
61 Source18: %{name}.service
62 Source22: http://www.modsecurity.org/tarball/%{modsecurity_version}/modsecurity-%{modsecurity_version}.tar.gz
63 # Source22-md5: 215a96d679a5b0fadcf13b5d09b35422
64 Source101: https://github.com/arut/nginx-rtmp-module/archive/v%{rtmp_version}/%{name}-rtmp-module-%{rtmp_version}.tar.gz
65 # Source101-md5: 639ac2b78103adaccbcfe484a92acf44
66 Source102: https://github.com/vozlt/nginx-module-vts/archive/v%{vts_version}.tar.gz
67 # Source102-md5: 409a10dbd85e0b807cc77eecec29a3b5
68 Patch0: %{name}-no-Werror.patch
69 Patch1: %{name}-modsecurity-xheaders.patch
70 URL: http://nginx.org/
71 BuildRequires: mailcap
72 BuildRequires: pcre-devel
73 BuildRequires: rpmbuild(macros) >= 1.644
74 BuildRequires: zlib-devel
76 BuildRequires: GeoIP-devel
79 BuildRequires: gd-devel
81 %if %{with modsecurity}
82 BuildRequires: lua-devel
85 BuildRequires: perl-CGI
86 BuildRequires: perl-devel
88 BuildRequires: rpm-perlprov
91 BuildRequires: openssl-devel >= %{ssl_version}
92 Requires: openssl >= %{ssl_version}
95 BuildRequires: libxslt-devel
98 Provides: group(nginx)
101 Provides: webserver(access)
102 Provides: webserver(alias)
103 Provides: webserver(auth)
104 Provides: webserver(expires)
105 Provides: webserver(headers)
106 Provides: webserver(indexfile)
107 Provides: webserver(log)
108 Provides: webserver(mime)
109 Provides: webserver(reqtimeout)
110 Provides: webserver(rewrite)
111 Provides: webserver(setenv)
112 Conflicts: logrotate < 3.8.0
113 Requires(post,preun): /sbin/chkconfig
114 Requires(post,preun,postun): systemd-units >= 38
115 Requires(postun): /usr/sbin/groupdel
116 Requires(postun): /usr/sbin/userdel
117 Requires(pre): /bin/id
118 Requires(pre): /usr/bin/getgid
119 Requires(pre): /usr/sbin/groupadd
120 Requires(pre): /usr/sbin/useradd
121 Requires: rc-scripts >= 0.2.0
122 Requires: systemd-units >= 38
123 Suggests: vim-syntax-nginx
124 Obsoletes: nginx-common < 1.13.3
125 Obsoletes: nginx-light < 1.13.3
126 Obsoletes: nginx-standard < 1.13.3
127 Conflicts: rpm < 4.4.2-0.2
128 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
130 %define _sysconfdir /etc/%{name}
131 %define _nginxdir /home/services/%{name}
133 # minimizing restarts logics. we restart webserver:
135 # 1. at the end of transaction. (posttrans, feature from rpm 4.4.2)
136 # 2. first install of module (post: $1 = 1)
137 # 2. uninstall of module (postun: $1 == 0)
139 # the strict internal deps between modules and
140 # main package are very important for all this to work.
142 # restart webserver at the end of transaction
144 %define restart_webserver \
145 %systemd_post %{name}.service \
146 %service %{name} force-reload \
149 # macro called at module post scriptlet
150 %define module_post \
151 if [ "$1" = "1" ]; then \
155 # macro called at module postun scriptlet
156 %define module_postun \
157 if [ "$1" = "0" ]; then \
161 # it's sooo annoying to write them
162 %define module_scripts() \
170 nginx ("engine x") is a high-performance HTTP server and reverse
171 proxy, as well as an IMAP/POP3 proxy server. nginx was written by Igor
172 Sysoev for Rambler.ru, Russia's second-most visited website, where it
173 has been running in production for over two and a half years. Igor has
174 released the source code under a BSD-like license. Although still in
175 beta, nginx is known for its stability, rich feature set, simple
176 configuration, and low resource consumption.
178 %description -l pl.UTF-8
179 nginx ("engine x") jest wysokowydajnym serwerem HTTP, odwrotnym proxy
180 a także IMAP/POP3 proxy. nginx został napisany przez Igora Sysoeva na
181 potrzeby serwisu Rambler.ru. Jest to drugi pod względem ilości
182 odwiedzin serwis w Rosji i działa od ponad dwóch i pół roku. Igor
183 opublikował źródła na licencji BSD. Mimo, że projekt jest ciągle w
184 fazie beta, już zasłynął dzięki stabilności, bogactwu dodatków,
185 prostej konfiguracji oraz małej "zasobożerności".
187 %package mod_http_geoip
188 Summary: Nginx HTTP geoip module
190 Requires: %{name} = %{version}-%{release}
193 %description mod_http_geoip
194 Nginx HTTP geoip module.
196 %package mod_stream_geoip
197 Summary: Nginx stream geoip module
199 Requires: %{name} = %{version}-%{release}
200 Requires: %{name}-mod_stream = %{version}-%{release}
203 %description mod_stream_geoip
204 Nginx stream geoip module.
206 %package mod_http_image_filter
207 Summary: Nginx HTTP image filter module
209 Requires: %{name} = %{version}-%{release}
211 %description mod_http_image_filter
212 Nginx HTTP image filter module.
214 %package mod_http_perl
215 Summary: Nginx HTTP Perl module
216 Group: Networking/Daemons/HTTP
217 Requires: %{name} = %{version}-%{release}
219 %description mod_http_perl
220 Nginx HTTP Perl module.
222 %package mod_http_xslt_filter
223 Summary: Nginx XSLT module
225 Requires: %{name} = %{version}-%{release}
227 %description mod_http_xslt_filter
231 Summary: Nginx mail module
232 Group: Networking/Daemons/HTTP
233 Requires: %{name} = %{version}-%{release}
235 %description mod_mail
239 Summary: Nginx virtual host traffic status module
240 Group: Networking/Daemons/HTTP
241 Requires: %{name} = %{version}-%{release}
244 Nginx virtual host traffic status module.
247 Summary: Nginx stream modules
249 Requires: %{name} = %{version}-%{release}
251 %description mod_stream
252 Nginx stream modules.
254 %package -n monit-rc-nginx
255 Summary: nginx support for monit
256 Summary(pl.UTF-8): Wsparcie nginx dla monit
257 Group: Applications/System
258 Requires: %{name} = %{version}-%{release}
261 %description -n monit-rc-nginx
262 monitrc file for monitoring nginx webserver.
264 %description -n monit-rc-nginx -l pl.UTF-8
265 Plik monitrc do monitorowania serwera WWW nginx.
268 %setup -q %{?with_rtmp:-a101} %{?with_modsecurity:-a22} %{?with_vts:-a102}
270 %{?with_modsecurity:%patch1 -p0}
273 mv nginx-rtmp-module-%{rtmp_version} nginx-rtmp-module
277 mv nginx-module-vts-%{vts_version} nginx-vts-module
280 # build mime.types.conf
281 #sh %{SOURCE17} /etc/mime.types
284 # NB: not autoconf generated configure
285 cp -f configure auto/
288 --prefix=%{_prefix} \
289 --modules-path=%{_libdir}/%{name}/modules \
290 --sbin-path=%{_sbindir}/%{name} \
291 --conf-path=%{_sysconfdir}/%{name}.conf \
292 --error-log-path=%{_localstatedir}/log/%{name}/error.log \
293 --http-log-path=%{_localstatedir}/log/%{name}/access.log \
294 --pid-path=%{_localstatedir}/run/%{name}.pid \
295 --lock-path=%{_localstatedir}/lock/subsys/%{name} \
296 --http-client-body-temp-path=%{_localstatedir}/cache/%{name}/client_body_temp \
297 --http-fastcgi-temp-path=%{_localstatedir}/cache/%{name}/fastcgi_temp \
298 --http-proxy-temp-path=%{_localstatedir}/cache/%{name}/proxy_temp \
299 --http-uwsgi-temp-path=%{_localstatedir}/cache/%{name}/uwsgi_temp \
300 --http-scgi-temp-path=%{_localstatedir}/cache/%{name}/scgi_temp \
303 %{?with_select:--with-select_module} \
304 %{?with_poll:--with-poll_module} \
305 %{?with_rtsig:--with-rtsig_module} \
306 %{?with_perl:--with-http_perl_module=dynamic} \
307 %{?with_gd:--with-http_image_filter_module=dynamic} \
308 %{?with_xslt:--with-http_xslt_module=dynamic} \
309 %{?with_geoip:--with-http_geoip_module=dynamic} \
310 %{?with_geoip:--with-stream_geoip_module=dynamic} \
312 --with-mail=dynamic \
313 --with-mail_ssl_module \
316 --with-stream=dynamic \
317 --with-stream_ssl_module \
319 --with-cc="%{__cc}" \
320 --with-cc-opt="%{rpmcflags}" \
321 --with-ld-opt="%{rpmldflags}" \
322 %{?with_debug:--with-debug} \
323 %{?with_addition:--with-http_addition_module} \
324 %{?with_dav:--with-http_dav_module} \
325 %{?with_flv:--with-http_flv_module} \
326 %{?with_sub:--with-http_sub_module} \
327 %{?with_realip:--with-http_realip_module} \
328 %{?with_stub_status:--with-http_stub_status_module} \
329 %{?with_ssl:--with-http_ssl_module} \
330 %{!?with_http_browser:--without-http_browser_module} \
331 %{?with_rtmp:--add-module=./nginx-rtmp-module} \
332 %{?with_vts:--add-dynamic-module=./nginx-vts-module} \
333 %{?with_auth_request:--with-http_auth_request_module} \
334 %{?with_threads:--with-threads} \
335 %{?with_http2:--with-http_v2_module} \
336 %{?with_modsecurity:--add-module=modsecurity-%{modsecurity_version}/nginx/modsecurity} \
337 --with-http_secure_link_module \
342 %if %{with modsecurity}
343 cd modsecurity-%{modsecurity_version}
346 --enable-standalone-module \
355 rm -rf $RPM_BUILD_ROOT
356 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d \
357 $RPM_BUILD_ROOT%{_nginxdir}/{cgi-bin,html,errors} \
358 $RPM_BUILD_ROOT%{_localstatedir}/log/{%{name},archive/%{name}} \
359 $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name} \
360 $RPM_BUILD_ROOT%{_localstatedir}/lock/subsys/%{name} \
361 $RPM_BUILD_ROOT{%{_sbindir},%{_sysconfdir}/{conf,modules,vhosts,webapps}.d} \
362 $RPM_BUILD_ROOT%{_sysconfdir}/snippets \
363 $RPM_BUILD_ROOT/etc/{logrotate.d,monit} \
364 $RPM_BUILD_ROOT{%{systemdunitdir},/etc/systemd/system}
368 DESTDIR=$RPM_BUILD_ROOT
370 %{__rm} $RPM_BUILD_ROOT%{_sysconfdir}/*.default
372 cp -p %{_sourcedir}/%{name}.conf $RPM_BUILD_ROOT%{_sysconfdir}
373 cp -p %{_sourcedir}/%{name}.service $RPM_BUILD_ROOT%{systemdunitdir}
374 cp -p %{_sourcedir}/%{name}.monitrc $RPM_BUILD_ROOT/etc/monit
375 install -p %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
377 cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
378 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/proxy.conf
379 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/mime.types
380 rm -r $RPM_BUILD_ROOT%{_prefix}/html
381 cp -p html/index.html $RPM_BUILD_ROOT%{_nginxdir}/html
382 cp -p html/50x.html $RPM_BUILD_ROOT%{_nginxdir}/errors
383 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_nginxdir}/html/favicon.ico
386 local module=ngx_${1}_module.so conffile=mod_$1.conf
387 printf 'load_module "%{_libdir}/%{name}/modules/%s";' "$module" \
388 > $RPM_BUILD_ROOT%{_sysconfdir}/modules.d/$conffile
392 %{__rm} $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod
393 %{__rm} $RPM_BUILD_ROOT%{perl_vendorarch}/auto/nginx/.packlist
394 load_module http_perl
398 load_module http_geoip
399 load_module stream_geoip
402 load_module http_image_filter
405 load_module http_xslt_filter
410 %{?with_vts:load_module http_vhost_traffic_status}
416 rm -rf $RPM_BUILD_ROOT
419 %groupadd -r -g 213 %{name}
421 %useradd -r -u 213 -d /usr/share/empty -s /bin/false -c "Nginx HTTP User" -g %{name} %{name}
422 %addusertogroup %{name} http
425 for a in access.log error.log; do
426 if [ ! -f /var/log/%{name}/$a ]; then
428 touch /var/log/%{name}/$a
429 chown nginx:nginx /var/log/%{name}/$a
430 chmod 644 /var/log/%{name}/$a
433 /sbin/chkconfig --add %{name}
439 if [ "$1" = "0" ];then
440 %service %{name} stop
441 /sbin/chkconfig --del %{name}
443 %systemd_preun %{name}.service
446 if [ "$1" = "0" ]; then
452 %module_scripts mod_http_geoip
453 %module_scripts mod_http_image_filter
454 %module_scripts mod_http_perl
455 %module_scripts mod_http_xslt_filter
456 %module_scripts mod_mail
457 %module_scripts mod_vts
458 %module_scripts mod_stream
459 %module_scripts mod_stream_geoip
462 %defattr(644,root,root,755)
463 %doc CHANGES LICENSE README html/index.html conf/nginx.conf
464 %doc %lang(ru) CHANGES.ru
465 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/%{name}
466 %attr(754,root,root) /etc/rc.d/init.d/%{name}
467 %dir %attr(750,root,nginx) %{_sysconfdir}
468 %dir %{_sysconfdir}/conf.d
469 %dir %{_sysconfdir}/modules.d
470 %dir %{_sysconfdir}/snippets
471 %dir %{_sysconfdir}/vhosts.d
472 %dir %{_sysconfdir}/webapps.d
473 %attr(640,root,root) %{_sysconfdir}/mime.types
474 %attr(640,root,root) %{_sysconfdir}/koi-utf
475 %attr(640,root,root) %{_sysconfdir}/koi-win
476 %attr(640,root,root) %{_sysconfdir}/win-utf
477 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi.conf
478 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nginx.conf
479 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/proxy.conf
480 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi_params
481 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/scgi_params
482 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi_params
483 %attr(755,root,root) %{_sbindir}/%{name}
484 %dir %{_libdir}/%{name}
485 %dir %{_libdir}/%{name}/modules
486 %{systemdunitdir}/%{name}.service
488 %attr(750,nginx,logs) %dir /var/log/archive/%{name}
489 %attr(750,nginx,logs) /var/log/%{name}
490 %attr(770,root,nginx) /var/cache/%{name}
493 %dir %{_nginxdir}/cgi-bin
494 %dir %{_nginxdir}/html
495 %dir %{_nginxdir}/errors
496 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/html/*
497 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/errors/*
500 %files mod_http_geoip
501 %defattr(644,root,root,755)
502 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_geoip.conf
503 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_geoip_module.so
505 %files mod_stream_geoip
506 %defattr(644,root,root,755)
507 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream_geoip.conf
508 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_geoip_module.so
512 %files mod_http_image_filter
513 %defattr(644,root,root,755)
514 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_image_filter.conf
515 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_image_filter_module.so
520 %defattr(644,root,root,755)
521 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_perl.conf
522 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_perl_module.so
523 %dir %{perl_vendorarch}/auto/%{name}
524 %attr(755,root,root) %{perl_vendorarch}/auto/%{name}/%{name}.so
525 %{perl_vendorarch}/%{name}.pm
526 %{_mandir}/man3/nginx.3pm*
530 %files mod_http_xslt_filter
531 %defattr(644,root,root,755)
532 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_xslt_filter.conf
533 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_xslt_filter_module.so
538 %defattr(644,root,root,755)
539 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_mail.conf
540 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_mail_module.so
545 %defattr(644,root,root,755)
546 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_vhost_traffic_status.conf
547 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_vhost_traffic_status_module.so
552 %defattr(644,root,root,755)
553 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream.conf
554 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_module.so
557 %files -n monit-rc-nginx
558 %defattr(644,root,root,755)
559 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/monit/%{name}.monitrc