2 # - /etc/sysconfig/nginx file
3 # - missing perl build/install requires
4 # - add njs: https://nginx.org/en/docs/njs/
6 # Conditional build for nginx:
8 %bcond_with debug # enable debug logging: http://nginx.org/en/docs/debugging_log.html
9 %bcond_without threads # thread pool support
11 %bcond_without addition # http addition module
12 %bcond_without auth_request # auth_request module
13 %bcond_without dav # WebDAV
14 %bcond_without flv # http FLV module
15 %bcond_without gd # without http image filter module
16 %bcond_without geoip # without http geoip module and stream geoip module
17 %bcond_without http2 # HTTP/2 module
18 %bcond_without mail # don't build imap/mail proxy
19 %bcond_without perl # don't build with perl module
20 %bcond_without poll # poll module
21 %bcond_without realip # real ip (behind proxy)
22 %bcond_without select # select module
23 %bcond_without ssl # ssl support and http ssl module
24 %bcond_without stream # TCP/UDP proxy module
25 %bcond_without stub_status # http stub status module
26 %bcond_without sub # ngx_http_sub_module
27 %bcond_without xslt # without http xslt module
28 %bcond_with http_browser # http browser module (header "User-agent" parser)
29 %bcond_with modsecurity # modsecurity module
30 %bcond_with rtmp # rtmp support
31 %bcond_without vts # virtual host traffic status module
37 %define ssl_version 1.0.2
38 %define rtmp_version 1.2.1
39 %define vts_version 0.1.18
40 %define modsecurity_version 2.9.3
41 Summary: High perfomance HTTP and reverse proxy server
42 Summary(pl.UTF-8): Serwer HTTP i odwrotne proxy o wysokiej wydajności
44 # - stable: production quality with stable API
45 # - mainline: production quality but API can change
46 # http://nginx.org/en/download.html
51 Group: Networking/Daemons/HTTP
52 Source0: http://nginx.org/download/%{name}-%{version}.tar.gz
53 # Source0-md5: 45a80f75336c980d240987badc3dcf60
54 Source1: http://nginx.net/favicon.ico
55 # Source1-md5: 2aaf2115c752cbdbfb8a2f0b3c3189ab
57 Source3: %{name}.logrotate
59 Source6: %{name}.monitrc
61 Source14: %{name}.conf
62 Source17: %{name}-mime.types.sh
63 Source18: %{name}.service
64 Source22: http://www.modsecurity.org/tarball/%{modsecurity_version}/modsecurity-%{modsecurity_version}.tar.gz
65 # Source22-md5: 215a96d679a5b0fadcf13b5d09b35422
66 Source101: https://github.com/arut/nginx-rtmp-module/archive/v%{rtmp_version}/%{name}-rtmp-module-%{rtmp_version}.tar.gz
67 # Source101-md5: 639ac2b78103adaccbcfe484a92acf44
68 Source102: https://github.com/vozlt/nginx-module-vts/archive/v%{vts_version}.tar.gz
69 # Source102-md5: 409a10dbd85e0b807cc77eecec29a3b5
70 Patch0: %{name}-no-Werror.patch
71 Patch1: %{name}-modsecurity-xheaders.patch
72 URL: http://nginx.org/
73 BuildRequires: mailcap
74 BuildRequires: pcre-devel
75 BuildRequires: rpmbuild(macros) >= 1.644
76 BuildRequires: zlib-devel
78 BuildRequires: GeoIP-devel
81 BuildRequires: gd-devel
83 %if %{with modsecurity}
84 BuildRequires: lua-devel
87 BuildRequires: perl-CGI
88 BuildRequires: perl-devel
90 BuildRequires: rpm-perlprov
93 BuildRequires: openssl-devel >= %{ssl_version}
94 Requires: openssl >= %{ssl_version}
97 BuildRequires: libxslt-devel
100 Provides: group(nginx)
101 Provides: user(nginx)
103 Provides: webserver(access)
104 Provides: webserver(alias)
105 Provides: webserver(auth)
106 Provides: webserver(expires)
107 Provides: webserver(headers)
108 Provides: webserver(indexfile)
109 Provides: webserver(log)
110 Provides: webserver(mime)
111 Provides: webserver(reqtimeout)
112 Provides: webserver(rewrite)
113 Provides: webserver(setenv)
114 Conflicts: logrotate < 3.8.0
115 Requires(post,preun): /sbin/chkconfig
116 Requires(post,preun,postun): systemd-units >= 38
117 Requires(postun): /usr/sbin/groupdel
118 Requires(postun): /usr/sbin/userdel
119 Requires(pre): /bin/id
120 Requires(pre): /usr/bin/getgid
121 Requires(pre): /usr/sbin/groupadd
122 Requires(pre): /usr/sbin/useradd
123 Requires: rc-scripts >= 0.2.0
124 Requires: systemd-units >= 38
125 Suggests: vim-syntax-nginx
126 Obsoletes: nginx-common < 1.13.3
127 Obsoletes: nginx-light < 1.13.3
128 Obsoletes: nginx-standard < 1.13.3
129 Conflicts: rpm < 4.4.2-0.2
130 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
132 %define _sysconfdir /etc/%{name}
133 %define _nginxdir /home/services/%{name}
135 # minimizing restarts logics. we restart webserver:
137 # 1. at the end of transaction. (posttrans, feature from rpm 4.4.2)
138 # 2. first install of module (post: $1 = 1)
139 # 2. uninstall of module (postun: $1 == 0)
141 # the strict internal deps between modules and
142 # main package are very important for all this to work.
144 # restart webserver at the end of transaction
146 %define restart_webserver \
147 %systemd_post %{name}.service \
148 %service %{name} force-reload \
151 # macro called at module post scriptlet
152 %define module_post \
153 if [ "$1" = "1" ]; then \
157 # macro called at module postun scriptlet
158 %define module_postun \
159 if [ "$1" = "0" ]; then \
163 # it's sooo annoying to write them
164 %define module_scripts() \
172 nginx ("engine x") is a high-performance HTTP server and reverse
173 proxy, as well as an IMAP/POP3 proxy server. nginx was written by Igor
174 Sysoev for Rambler.ru, Russia's second-most visited website, where it
175 has been running in production for over two and a half years. Igor has
176 released the source code under a BSD-like license. Although still in
177 beta, nginx is known for its stability, rich feature set, simple
178 configuration, and low resource consumption.
180 %description -l pl.UTF-8
181 nginx ("engine x") jest wysokowydajnym serwerem HTTP, odwrotnym proxy
182 a także IMAP/POP3 proxy. nginx został napisany przez Igora Sysoeva na
183 potrzeby serwisu Rambler.ru. Jest to drugi pod względem ilości
184 odwiedzin serwis w Rosji i działa od ponad dwóch i pół roku. Igor
185 opublikował źródła na licencji BSD. Mimo, że projekt jest ciągle w
186 fazie beta, już zasłynął dzięki stabilności, bogactwu dodatków,
187 prostej konfiguracji oraz małej "zasobożerności".
189 %package mod_http_geoip
190 Summary: Nginx HTTP geoip module
192 Requires: %{name} = %{version}-%{release}
195 %description mod_http_geoip
196 Nginx HTTP geoip module.
198 %package mod_stream_geoip
199 Summary: Nginx stream geoip module
201 Requires: %{name} = %{version}-%{release}
202 Requires: %{name}-mod_stream = %{version}-%{release}
205 %description mod_stream_geoip
206 Nginx stream geoip module.
208 %package mod_http_image_filter
209 Summary: Nginx HTTP image filter module
211 Requires: %{name} = %{version}-%{release}
213 %description mod_http_image_filter
214 Nginx HTTP image filter module.
216 %package mod_http_perl
217 Summary: Nginx HTTP Perl module
218 Group: Networking/Daemons/HTTP
219 Requires: %{name} = %{version}-%{release}
221 %description mod_http_perl
222 Nginx HTTP Perl module.
224 %package mod_http_xslt_filter
225 Summary: Nginx XSLT module
227 Requires: %{name} = %{version}-%{release}
229 %description mod_http_xslt_filter
233 Summary: Nginx mail module
234 Group: Networking/Daemons/HTTP
235 Requires: %{name} = %{version}-%{release}
237 %description mod_mail
241 Summary: Nginx virtual host traffic status module
242 Group: Networking/Daemons/HTTP
243 Requires: %{name} = %{version}-%{release}
246 Nginx virtual host traffic status module.
249 Summary: Nginx stream modules
251 Requires: %{name} = %{version}-%{release}
253 %description mod_stream
254 Nginx stream modules.
256 %package -n monit-rc-nginx
257 Summary: nginx support for monit
258 Summary(pl.UTF-8): Wsparcie nginx dla monit
259 Group: Applications/System
260 Requires: %{name} = %{version}-%{release}
263 %description -n monit-rc-nginx
264 monitrc file for monitoring nginx webserver.
266 %description -n monit-rc-nginx -l pl.UTF-8
267 Plik monitrc do monitorowania serwera WWW nginx.
270 %setup -q %{?with_rtmp:-a101} %{?with_modsecurity:-a22} %{?with_vts:-a102}
272 %{?with_modsecurity:%patch1 -p0}
275 mv nginx-rtmp-module-%{rtmp_version} nginx-rtmp-module
279 mv nginx-module-vts-%{vts_version} nginx-vts-module
282 # build mime.types.conf
283 #sh %{SOURCE17} /etc/mime.types
286 # NB: not autoconf generated configure
287 cp -f configure auto/
290 --prefix=%{_prefix} \
291 --modules-path=%{_libdir}/%{name}/modules \
292 --sbin-path=%{_sbindir}/%{name} \
293 --conf-path=%{_sysconfdir}/%{name}.conf \
294 --error-log-path=%{_localstatedir}/log/%{name}/error.log \
295 --http-log-path=%{_localstatedir}/log/%{name}/access.log \
296 --pid-path=%{_localstatedir}/run/%{name}.pid \
297 --lock-path=%{_localstatedir}/lock/subsys/%{name} \
298 --http-client-body-temp-path=%{_localstatedir}/cache/%{name}/client_body_temp \
299 --http-fastcgi-temp-path=%{_localstatedir}/cache/%{name}/fastcgi_temp \
300 --http-proxy-temp-path=%{_localstatedir}/cache/%{name}/proxy_temp \
301 --http-uwsgi-temp-path=%{_localstatedir}/cache/%{name}/uwsgi_temp \
302 --http-scgi-temp-path=%{_localstatedir}/cache/%{name}/scgi_temp \
305 %{?with_select:--with-select_module} \
306 %{?with_poll:--with-poll_module} \
307 %{?with_rtsig:--with-rtsig_module} \
308 %{?with_perl:--with-http_perl_module=dynamic} \
309 %{?with_gd:--with-http_image_filter_module=dynamic} \
310 %{?with_xslt:--with-http_xslt_module=dynamic} \
311 %{?with_geoip:--with-http_geoip_module=dynamic} \
312 %{?with_geoip:--with-stream_geoip_module=dynamic} \
314 --with-mail=dynamic \
315 --with-mail_ssl_module \
318 --with-stream=dynamic \
319 --with-stream_ssl_module \
321 --with-cc="%{__cc}" \
322 --with-cc-opt="%{rpmcflags}" \
323 --with-ld-opt="%{rpmldflags}" \
324 %{?with_debug:--with-debug} \
325 %{?with_addition:--with-http_addition_module} \
326 %{?with_dav:--with-http_dav_module} \
327 %{?with_flv:--with-http_flv_module} \
328 %{?with_sub:--with-http_sub_module} \
329 %{?with_realip:--with-http_realip_module} \
330 %{?with_stub_status:--with-http_stub_status_module} \
331 %{?with_ssl:--with-http_ssl_module} \
332 %{!?with_http_browser:--without-http_browser_module} \
333 %{?with_rtmp:--add-module=./nginx-rtmp-module} \
334 %{?with_vts:--add-dynamic-module=./nginx-vts-module} \
335 %{?with_auth_request:--with-http_auth_request_module} \
336 %{?with_threads:--with-threads} \
337 %{?with_http2:--with-http_v2_module} \
338 %{?with_modsecurity:--add-module=modsecurity-%{modsecurity_version}/nginx/modsecurity} \
339 --with-http_secure_link_module \
344 %if %{with modsecurity}
345 cd modsecurity-%{modsecurity_version}
348 --enable-standalone-module \
357 rm -rf $RPM_BUILD_ROOT
358 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d \
359 $RPM_BUILD_ROOT%{_nginxdir}/{cgi-bin,html,errors} \
360 $RPM_BUILD_ROOT%{_localstatedir}/log/{%{name},archive/%{name}} \
361 $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name} \
362 $RPM_BUILD_ROOT%{_localstatedir}/lock/subsys/%{name} \
363 $RPM_BUILD_ROOT{%{_sbindir},%{_sysconfdir}/{conf,modules,vhosts,webapps}.d} \
364 $RPM_BUILD_ROOT%{_sysconfdir}/snippets \
365 $RPM_BUILD_ROOT/etc/{logrotate.d,monit} \
366 $RPM_BUILD_ROOT{%{systemdunitdir},/etc/systemd/system}
370 DESTDIR=$RPM_BUILD_ROOT
372 %{__rm} $RPM_BUILD_ROOT%{_sysconfdir}/*.default
374 cp -p %{_sourcedir}/%{name}.conf $RPM_BUILD_ROOT%{_sysconfdir}
375 cp -p %{_sourcedir}/%{name}.service $RPM_BUILD_ROOT%{systemdunitdir}
376 cp -p %{_sourcedir}/%{name}.monitrc $RPM_BUILD_ROOT/etc/monit
377 install -p %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
379 cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
380 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/proxy.conf
381 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/mime.types
382 rm -r $RPM_BUILD_ROOT%{_prefix}/html
383 cp -p html/index.html $RPM_BUILD_ROOT%{_nginxdir}/html
384 cp -p html/50x.html $RPM_BUILD_ROOT%{_nginxdir}/errors
385 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_nginxdir}/html/favicon.ico
388 local module=ngx_${1}_module.so conffile=mod_$1.conf
389 printf 'load_module "%{_libdir}/%{name}/modules/%s";' "$module" \
390 > $RPM_BUILD_ROOT%{_sysconfdir}/modules.d/$conffile
394 %{__rm} $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod
395 %{__rm} $RPM_BUILD_ROOT%{perl_vendorarch}/auto/nginx/.packlist
396 load_module http_perl
400 load_module http_geoip
401 load_module stream_geoip
404 load_module http_image_filter
407 load_module http_xslt_filter
412 %{?with_vts:load_module http_vhost_traffic_status}
418 rm -rf $RPM_BUILD_ROOT
421 %groupadd -r -g 213 %{name}
423 %useradd -r -u 213 -d /usr/share/empty -s /bin/false -c "Nginx HTTP User" -g %{name} %{name}
424 %addusertogroup %{name} http
427 for a in access.log error.log; do
428 if [ ! -f /var/log/%{name}/$a ]; then
430 touch /var/log/%{name}/$a
431 chown nginx:nginx /var/log/%{name}/$a
432 chmod 644 /var/log/%{name}/$a
435 /sbin/chkconfig --add %{name}
441 if [ "$1" = "0" ];then
442 %service %{name} stop
443 /sbin/chkconfig --del %{name}
445 %systemd_preun %{name}.service
448 if [ "$1" = "0" ]; then
454 %module_scripts mod_http_geoip
455 %module_scripts mod_http_image_filter
456 %module_scripts mod_http_perl
457 %module_scripts mod_http_xslt_filter
458 %module_scripts mod_mail
459 %module_scripts mod_vts
460 %module_scripts mod_stream
461 %module_scripts mod_stream_geoip
464 %defattr(644,root,root,755)
465 %doc CHANGES LICENSE README html/index.html conf/nginx.conf
466 %doc %lang(ru) CHANGES.ru
467 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/%{name}
468 %attr(754,root,root) /etc/rc.d/init.d/%{name}
469 %dir %attr(750,root,nginx) %{_sysconfdir}
470 %dir %{_sysconfdir}/conf.d
471 %dir %{_sysconfdir}/modules.d
472 %dir %{_sysconfdir}/snippets
473 %dir %{_sysconfdir}/vhosts.d
474 %dir %{_sysconfdir}/webapps.d
475 %attr(640,root,root) %{_sysconfdir}/mime.types
476 %attr(640,root,root) %{_sysconfdir}/koi-utf
477 %attr(640,root,root) %{_sysconfdir}/koi-win
478 %attr(640,root,root) %{_sysconfdir}/win-utf
479 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi.conf
480 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nginx.conf
481 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/proxy.conf
482 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fastcgi_params
483 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/scgi_params
484 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi_params
485 %attr(755,root,root) %{_sbindir}/%{name}
486 %dir %{_libdir}/%{name}
487 %dir %{_libdir}/%{name}/modules
488 %{systemdunitdir}/%{name}.service
490 %attr(750,nginx,logs) %dir /var/log/archive/%{name}
491 %attr(750,nginx,logs) /var/log/%{name}
492 %attr(770,root,nginx) /var/cache/%{name}
495 %dir %{_nginxdir}/cgi-bin
496 %dir %{_nginxdir}/html
497 %dir %{_nginxdir}/errors
498 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/html/*
499 %config(noreplace,missingok) %verify(not md5 mtime size) %{_nginxdir}/errors/*
502 %files mod_http_geoip
503 %defattr(644,root,root,755)
504 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_geoip.conf
505 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_geoip_module.so
507 %files mod_stream_geoip
508 %defattr(644,root,root,755)
509 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream_geoip.conf
510 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_geoip_module.so
514 %files mod_http_image_filter
515 %defattr(644,root,root,755)
516 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_image_filter.conf
517 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_image_filter_module.so
522 %defattr(644,root,root,755)
523 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_perl.conf
524 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_perl_module.so
525 %dir %{perl_vendorarch}/auto/%{name}
526 %attr(755,root,root) %{perl_vendorarch}/auto/%{name}/%{name}.so
527 %{perl_vendorarch}/%{name}.pm
528 %{_mandir}/man3/nginx.3pm*
532 %files mod_http_xslt_filter
533 %defattr(644,root,root,755)
534 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_xslt_filter.conf
535 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_xslt_filter_module.so
540 %defattr(644,root,root,755)
541 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_mail.conf
542 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_mail_module.so
547 %defattr(644,root,root,755)
548 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_http_vhost_traffic_status.conf
549 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_http_vhost_traffic_status_module.so
554 %defattr(644,root,root,755)
555 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/modules.d/mod_stream.conf
556 %attr(755,root,root) %{_libdir}/%{name}/modules/ngx_stream_module.so
559 %files -n monit-rc-nginx
560 %defattr(644,root,root,755)
561 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/monit/%{name}.monitrc