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
35 %define ssl_version 1.0.2
36 %define rtmp_version 1.1.11
37 %define modsecurity_version 2.9.2
38 Summary: High perfomance HTTP and reverse proxy server
39 Summary(pl.UTF-8): Serwer HTTP i odwrotne proxy o wysokiej wydajności
41 # - stable: production quality with stable API
42 # - mainline: production quality but API can change
47 Group: Networking/Daemons/HTTP
48 Source0: http://nginx.org/download/%{name}-%{version}.tar.gz
49 # Source0-md5: 42a3ca70cd292a149ba4f60862599245
50 Source1: http://nginx.net/favicon.ico
51 # Source1-md5: 2aaf2115c752cbdbfb8a2f0b3c3189ab
53 Source3: %{name}.logrotate
55 Source6: %{name}.monitrc
57 Source14: %{name}.conf
58 Source17: %{name}-mime.types.sh
59 Source18: %{name}.service
60 Source22: http://www.modsecurity.org/tarball/%{modsecurity_version}/modsecurity-%{modsecurity_version}.tar.gz
61 # Source22-md5: 4d9454efb19269c4288ae408ea438b76
62 Source101: https://github.com/arut/nginx-rtmp-module/archive/v%{rtmp_version}/%{name}-rtmp-module-%{rtmp_version}.tar.gz
63 # Source101-md5: a87ab77c4414f80d394d712cceb39016
64 Patch0: %{name}-no-Werror.patch
65 Patch1: %{name}-modsecurity-xheaders.patch
66 URL: http://nginx.org/
67 BuildRequires: mailcap
68 BuildRequires: pcre-devel
69 BuildRequires: rpmbuild(macros) >= 1.644
70 BuildRequires: zlib-devel
72 BuildRequires: GeoIP-devel
75 BuildRequires: gd-devel
77 %if %{with modsecurity}
78 BuildRequires: lua-devel
81 BuildRequires: perl-CGI
82 BuildRequires: perl-devel
84 BuildRequires: rpm-perlprov
87 BuildRequires: openssl-devel >= %{ssl_version}
88 Requires: openssl >= %{ssl_version}
91 BuildRequires: libxslt-devel
94 Provides: group(nginx)
97 Provides: webserver(access)
98 Provides: webserver(alias)
99 Provides: webserver(auth)
100 Provides: webserver(expires)
101 Provides: webserver(headers)
102 Provides: webserver(indexfile)
103 Provides: webserver(log)
104 Provides: webserver(mime)
105 Provides: webserver(reqtimeout)
106 Provides: webserver(rewrite)
107 Provides: webserver(setenv)
108 Conflicts: logrotate < 3.8.0
109 Requires(post,preun): /sbin/chkconfig
110 Requires(post,preun,postun): systemd-units >= 38
111 Requires(postun): /usr/sbin/groupdel
112 Requires(postun): /usr/sbin/userdel
113 Requires(pre): /bin/id
114 Requires(pre): /usr/bin/getgid
115 Requires(pre): /usr/sbin/groupadd
116 Requires(pre): /usr/sbin/useradd
117 Requires: rc-scripts >= 0.2.0
118 Requires: systemd-units >= 38
119 Suggests: vim-syntax-nginx
120 Conflicts: rpm < 4.4.2-0.2
121 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
123 %define _sysconfdir /etc/%{name}
124 %define _nginxdir /home/services/%{name}
126 # minimizing restarts logics. we restart webserver:
128 # 1. at the end of transaction. (posttrans, feature from rpm 4.4.2)
129 # 2. first install of module (post: $1 = 1)
130 # 2. uninstall of module (postun: $1 == 0)
132 # the strict internal deps between modules and
133 # main package are very important for all this to work.
135 # restart webserver at the end of transaction
137 %define restart_webserver \
138 %systemd_post %{name}.service \
139 %service %{name} force-reload \
142 # macro called at module post scriptlet
143 %define module_post \
144 if [ "$1" = "1" ]; then \
148 # macro called at module postun scriptlet
149 %define module_postun \
150 if [ "$1" = "0" ]; then \
154 # it's sooo annoying to write them
155 %define module_scripts() \
163 nginx ("engine x") is a high-performance HTTP server and reverse
164 proxy, as well as an IMAP/POP3 proxy server. nginx was written by Igor
165 Sysoev for Rambler.ru, Russia's second-most visited website, where it
166 has been running in production for over two and a half years. Igor has
167 released the source code under a BSD-like license. Although still in
168 beta, nginx is known for its stability, rich feature set, simple
169 configuration, and low resource consumption.
171 %description -l pl.UTF-8
172 nginx ("engine x") jest wysokowydajnym serwerem HTTP, odwrotnym proxy
173 a także IMAP/POP3 proxy. nginx został napisany przez Igora Sysoeva na
174 potrzeby serwisu Rambler.ru. Jest to drugi pod względem ilości
175 odwiedzin serwis w Rosji i działa od ponad dwóch i pół roku. Igor
176 opublikował źródła na licencji BSD. Mimo, że projekt jest ciągle w
177 fazie beta, już zasłynął dzięki stabilności, bogactwu dodatków,
178 prostej konfiguracji oraz małej "zasobożerności".
180 %package mod_http_geoip
181 Summary: Nginx HTTP geoip module
183 Requires: %{name} = %{version}-%{release}
186 %description mod_http_geoip
187 Nginx HTTP geoip module.
189 %package mod_stream_geoip
190 Summary: Nginx stream geoip module
192 Requires: %{name} = %{version}-%{release}
193 Requires: %{name}-mod_stream = %{version}-%{release}
196 %description mod_stream_geoip
197 Nginx stream geoip module.
199 %package mod_http_image_filter
200 Summary: Nginx HTTP image filter module
202 Requires: %{name} = %{version}-%{release}
204 %description mod_http_image_filter
205 Nginx HTTP image filter module.
207 %package mod_http_perl
208 Summary: Nginx HTTP Perl module
209 Group: Networking/Daemons/HTTP
210 Requires: %{name} = %{version}-%{release}
212 %description mod_http_perl
213 Nginx HTTP Perl module.
215 %package mod_http_xslt_filter
216 Summary: Nginx XSLT module
218 Requires: %{name} = %{version}-%{release}
220 %description mod_http_xslt_filter
224 Summary: Nginx mail module
225 Group: Networking/Daemons/HTTP
226 Requires: %{name} = %{version}-%{release}
228 %description mod_mail
232 Summary: Nginx stream modules
234 Requires: %{name} = %{version}-%{release}
236 %description mod_stream
237 Nginx stream modules.
239 %package -n monit-rc-nginx
240 Summary: nginx support for monit
241 Summary(pl.UTF-8): Wsparcie nginx dla monit
242 Group: Applications/System
243 Requires: %{name} = %{version}-%{release}
246 %description -n monit-rc-nginx
247 monitrc file for monitoring nginx webserver.
249 %description -n monit-rc-nginx -l pl.UTF-8
250 Plik monitrc do monitorowania serwera WWW nginx.
253 %setup -q %{?with_rtmp:-a101} %{?with_modsecurity:-a22}
255 %{?with_modsecurity:%patch1 -p0}
258 mv nginx-rtmp-module-%{rtmp_version} nginx-rtmp-module
261 # build mime.types.conf
262 #sh %{SOURCE17} /etc/mime.types
265 # NB: not autoconf generated configure
266 cp -f configure auto/
269 --prefix=%{_prefix} \
270 --modules-path=%{_libdir}/%{name}/modules \
271 --sbin-path=%{_sbindir}/%{name} \
272 --conf-path=%{_sysconfdir}/%{name}.conf \
273 --error-log-path=%{_localstatedir}/log/%{name}/error.log \
274 --http-log-path=%{_localstatedir}/log/%{name}/access.log \
275 --pid-path=%{_localstatedir}/run/%{name}.pid \
276 --lock-path=%{_localstatedir}/lock/subsys/%{name} \
277 --http-client-body-temp-path=%{_localstatedir}/cache/%{name}/client_body_temp \
278 --http-fastcgi-temp-path=%{_localstatedir}/cache/%{name}/fastcgi_temp \
279 --http-proxy-temp-path=%{_localstatedir}/cache/%{name}/proxy_temp \
280 --http-uwsgi-temp-path=%{_localstatedir}/cache/%{name}/uwsgi_temp \
283 %{?with_select:--with-select_module} \
284 %{?with_poll:--with-poll_module} \
285 %{?with_rtsig:--with-rtsig_module} \
286 %{?with_perl:--with-http_perl_module=dynamic} \
287 %{?with_gd:--with-http_image_filter_module=dynamic} \
288 %{?with_xslt:--with-http_xslt_module=dynamic} \
289 %{?with_geoip:--with-http_geoip_module=dynamic} \
290 %{?with_geoip:--with-stream_geoip_module=dynamic} \
292 --with-mail=dynamic \
293 --with-mail_ssl_module \
296 --with-stream=dynamic \
297 --with-stream_ssl_module \
299 --with-cc="%{__cc}" \
300 --with-cc-opt="%{rpmcflags}" \
301 --with-ld-opt="%{rpmldflags}" \
302 %{?with_debug:--with-debug} \
303 %{?with_addition:--with-http_addition_module} \
304 %{?with_dav:--with-http_dav_module} \
305 %{?with_flv:--with-http_flv_module} \
306 %{?with_sub:--with-http_sub_module} \
307 %{?with_realip:--with-http_realip_module} \
308 %{?with_stub_status:--with-http_stub_status_module} \
309 %{?with_ssl:--with-http_ssl_module} \
310 %{!?with_http_browser:--without-http_browser_module} \
311 %{?with_rtmp:--add-module=./nginx-rtmp-module} \
312 %{?with_auth_request:--with-http_auth_request_module} \
313 %{?with_threads:--with-threads} \
314 %{?with_http2:--with-http_v2_module} \
315 %{?with_modsecurity:--add-module=modsecurity-%{modsecurity_version}/nginx/modsecurity} \
316 --with-http_secure_link_module \
321 %if %{with modsecurity}
322 cd modsecurity-%{modsecurity_version}
325 --enable-standalone-module \
334 rm -rf $RPM_BUILD_ROOT
335 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d \
336 $RPM_BUILD_ROOT%{_nginxdir}/{cgi-bin,html,errors} \
337 $RPM_BUILD_ROOT%{_localstatedir}/log/{%{name},archive/%{name}} \
338 $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name} \
339 $RPM_BUILD_ROOT%{_localstatedir}/lock/subsys/%{name} \
340 $RPM_BUILD_ROOT{%{_sbindir},%{_sysconfdir}/{conf,modules,vhosts,webapps}.d} \
341 $RPM_BUILD_ROOT/etc/{logrotate.d,monit} \
342 $RPM_BUILD_ROOT{%{systemdunitdir},/etc/systemd/system}
346 DESTDIR=$RPM_BUILD_ROOT
348 %{__rm} $RPM_BUILD_ROOT%{_sysconfdir}/*.default
350 cp -p %{_sourcedir}/%{name}.conf $RPM_BUILD_ROOT%{_sysconfdir}
351 cp -p %{_sourcedir}/%{name}.service $RPM_BUILD_ROOT%{systemdunitdir}
352 cp -p %{_sourcedir}/%{name}.monitrc $RPM_BUILD_ROOT/etc/monit
353 install -p %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
355 cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
356 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/proxy.conf
357 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/mime.types
358 rm -r $RPM_BUILD_ROOT%{_prefix}/html
359 cp -p html/index.html $RPM_BUILD_ROOT%{_nginxdir}/html
360 cp -p html/50x.html $RPM_BUILD_ROOT%{_nginxdir}/errors
361 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_nginxdir}/html/favicon.ico
364 local module=ngx_${1}_module.so conffile=mod_$1.conf
365 printf 'load_module "%{_libdir}/%{name}/modules/%s";' "$module" \
366 > $RPM_BUILD_ROOT%{_sysconfdir}/modules.d/$conffile
370 %{__rm} $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod
371 %{__rm} $RPM_BUILD_ROOT%{perl_vendorarch}/auto/nginx/.packlist
372 load_module http_perl
376 load_module http_geoip
377 load_module stream_geoip
380 load_module http_image_filter
383 load_module http_xslt_filter
393 rm -rf $RPM_BUILD_ROOT
396 %groupadd -r -g 213 %{name}
398 %useradd -r -u 213 -d /usr/share/empty -s /bin/false -c "Nginx HTTP User" -g %{name} %{name}
399 %addusertogroup %{name} http
402 for a in access.log error.log; do
403 if [ ! -f /var/log/%{name}/$a ]; then
405 touch /var/log/%{name}/$a
406 chown nginx:nginx /var/log/%{name}/$a
407 chmod 644 /var/log/%{name}/$a
410 /sbin/chkconfig --add %{name}
416 if [ "$1" = "0" ];then
417 %service %{name} stop
418 /sbin/chkconfig --del %{name}
420 %systemd_preun %{name}.service
423 if [ "$1" = "0" ]; then
429 %module_scripts mod_http_geoip
430 %module_scripts mod_http_image_filter
431 %module_scripts mod_http_perl
432 %module_scripts mod_http_xslt_filter
433 %module_scripts mod_mail
434 %module_scripts mod_stream
435 %module_scripts mod_stream_geoip
438 %defattr(644,root,root,755)
439 %doc CHANGES LICENSE README html/index.html conf/nginx.conf
440 %doc %lang(ru) CHANGES.ru
441 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/%{name}
442 %attr(754,root,root) /etc/rc.d/init.d/%{name}
443 %dir %attr(750,root,nginx) %{_sysconfdir}
444 %dir %{_sysconfdir}/conf.d
445 %dir %{_sysconfdir}/modules.d
446 %dir %{_sysconfdir}/vhosts.d
447 %dir %{_sysconfdir}/webapps.d
448 %attr(640,root,root) %{_sysconfdir}/mime.types
449 %attr(640,root,root) %{_sysconfdir}/koi-utf
450 %attr(640,root,root) %{_sysconfdir}/koi-win
451 %attr(640,root,root) %{_sysconfdir}/win-utf
452 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi.conf
453 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nginx.conf
454 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/proxy.conf
455 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi_params
456 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/scgi_params
457 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi_params
458 %attr(755,root,root) %{_sbindir}/%{name}
459 %dir %{_libdir}/%{name}
460 %dir %{_libdir}/%{name}/modules
461 %{systemdunitdir}/%{name}.service
463 %attr(750,nginx,logs) %dir /var/log/archive/%{name}
464 %attr(750,nginx,logs) /var/log/%{name}
465 %attr(770,root,nginx) /var/cache/%{name}
468 %dir %{_nginxdir}/cgi-bin
469 %dir %{_nginxdir}/html
470 %dir %{_nginxdir}/errors
471 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/html/*
472 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/errors/*
475 %files mod_http_geoip
476 %defattr(644,root,root,755)
477 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_geoip.conf
478 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_geoip_module.so
480 %files mod_stream_geoip
481 %defattr(644,root,root,755)
482 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream_geoip.conf
483 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_geoip_module.so
487 %files mod_http_image_filter
488 %defattr(644,root,root,755)
489 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_image_filter.conf
490 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_image_filter_module.so
495 %defattr(644,root,root,755)
496 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_perl.conf
497 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_perl_module.so
498 %dir %{perl_vendorarch}/auto/%{name}
499 %attr(755,root,root) %{perl_vendorarch}/auto/%{name}/%{name}.so
500 %{perl_vendorarch}/%{name}.pm
501 %{_mandir}/man3/nginx.3pm*
505 %files mod_http_xslt_filter
506 %defattr(644,root,root,755)
507 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_xslt_filter.conf
508 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_xslt_filter_module.so
513 %defattr(644,root,root,755)
514 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_mail.conf
515 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_mail_module.so
520 %defattr(644,root,root,755)
521 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream.conf
522 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_module.so
525 %files -n monit-rc-nginx
526 %defattr(644,root,root,755)
527 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/monit/%{name}.monitrc