%global packagename nginx %global nginx_user www-data %global nginx_group %{nginx_user} %global nginx_home %{_localstatedir}/lib/nginx %global nginx_home_cache %{nginx_home}/cache %global nginx_logdir %{_localstatedir}/log/nginx %global nginx_confdir %{_sysconfdir}/nginx %global nginx_datadir %{_datadir}/nginx %global nginx_webroot %{nginx_datadir}/html %global gcc_version 8 %global module_ps 1.13.35.2 %global module_headers_more 0.33 %global module_cache_purge 2.5.1 %global module_vts 0.1.18 %global module_brotli 20201006 %global module_geoip2 3.3 %global module_echo 0.62 %global module_modsecurity 1.0.2 %global module_dynamic_etag 0.2.1 %global module_fancyindex 0.5.2 %global versionD 1.20.2 %define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) %ifarch x86_64 %bcond_with pagespeed %endif %bcond_with headersmore %bcond_with cachepurge %bcond_with etag %bcond_with vts %bcond_with brotli %bcond_with geoip2 %bcond_with echo %bcond_with modsecurity %bcond_with fancyindex Name: nginx-ex Version: 1.20.2 Release: 1%{?dist} Summary: A high performance web server and reverse proxy server Group: System Environment/Daemons License: 2-clause BSD-like license URL: http://nginx.org/ BuildRoot: %{_tmppath}/%{name}-%{versionD}-%{release}-root-%(%{__id_u} -n) Source0: https://nginx.org/download/nginx-%{versionD}.tar.gz Source1: nginx.service Source2: nginx.init Source3: nginx.logrotate Source4: nginx.conf Source5: nginx.upgrade.sh Source6: nginx.check-reload.sh Source10: security.conf Source11: general.conf Source12: example.com.conf %ifarch x86_64 Source101: https://nginxex-file.b-cdn.net/files/ngx_pagespeed-%{module_ps}-stable.tar.gz Source102: https://nginxex-file.b-cdn.net/files/psol-%{module_ps}-stable.tar.gz %endif Source103: https://nginxex-file.b-cdn.net/files/ngx_headers_more-%{module_headers_more}.tar.gz Source104: https://nginxex-file.b-cdn.net/files/ngx_cache_purge-%{module_cache_purge}.tar.gz Source105: https://nginxex-file.b-cdn.net/files/ngx_brotli-%{module_brotli}.tar.gz Source106: https://nginxex-file.b-cdn.net/files/ngx_module_vts-%{module_vts}.tar.gz Source107: https://nginxex-file.b-cdn.net/files/ngx_http_geoip2_module-%{module_geoip2}.tar.gz Source108: https://nginxex-file.b-cdn.net/files/ngx_echo-%{module_echo}.tar.gz Source109: https://nginxex-file.b-cdn.net/files/ngx_modsecurity-%{module_modsecurity}.tar.gz Source110: https://nginxex-file.b-cdn.net/files/ngx_dynamic_etag-%{module_dynamic_etag}.tar.gz Source111: https://nginxex-file.b-cdn.net/files/ngx_fancyindex-%{module_fancyindex}.tar.gz Patch0: nginx-version.patch Patch1: ngx_cloudflare_http2_hpack_1015003.patch Patch2: ngx_cloudflare_dynamic_tls_records_1015008.patch BuildRequires: libxslt-devel BuildRequires: openssl-devel BuildRequires: pcre-devel BuildRequires: zlib-devel BuildRequires: pcre BuildRequires: gd-devel BuildRequires: httpd-devel BuildRequires: libuuid-devel %if 0%{?rhel} == 8 BuildRequires: GeoIP-devel perl-Getopt-Long %endif Requires: gd Requires: pcre Requires(pre): shadow-utils %if %{use_systemd} BuildRequires: systemd Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %else Requires(post): chkconfig Requires(preun): chkconfig, initscripts Requires(postun): initscripts %endif %ifarch x86_64 %package module-pagespeed Version: %{versionD}+%{module_ps} Release: 1%{?dist} Summary: Nginx PageSpeed module Requires: nginx-ex = %{versionD}-%{release} %description module-pagespeed ngx_pagespeed speeds up your site and reduces page load time by automatically applying web performance best practices to pages and associated assets (CSS, JavaScript, images) without requiring you to modify your existing content or workflow. %endif %package module-headers-more Version: %{versionD}+%{module_headers_more} Release: 1%{?dist} Summary: Headers More Nginx module Requires: nginx-ex = %{versionD}-%{release} %description module-headers-more This module allows you to add, set, or clear any output or input header that you specify. %package module-cache-purge Version: %{versionD}+%{module_cache_purge} Release: 1%{?dist} Summary: Nginx Cache Purge module Requires: nginx-ex = %{versionD}-%{release} %description module-cache-purge The Nginx Cache Purge moduleis nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches. %package module-dynamic-etag Version: %{versionD}+%{module_dynamic_etag} Release: 1%{?dist} Summary: Nginx Cache Dynamic ETag module Requires: nginx-ex = %{versionD}-%{release} %description module-dynamic-etag Nginx Dynamic Purge module empowers your dynamic content with automatic ETag header. It allows client browsers to issue conditional GET requests to dynamic pages. And thus saves bandwidth and ensures better performance! %package module-fancyindex Version: %{versionD}+%{module_fancyindex} Release: 1%{?dist} Summary: Nginx Cache Fancyindex module Requires: nginx-ex = %{versionD}-%{release} %description module-fancyindex The Fancy Index module makes possible the generation of file listings, like the built-in autoindex module does, but adding a touch of style. %package module-vts Version: %{versionD}+%{module_vts} Release: 1%{?dist} Summary: Nginx VTS module Requires: nginx-ex = %{versionD}-%{release} %description module-vts This is an Nginx module that provides access to virtual host status information. It contains the current status such as servers, upstreams, caches. This is similar to the live activity monitoring of nginx plus. The built-in html is also taken from the demo page of old version. %package module-brotli Version: %{versionD}+%{module_brotli} Release: 1%{?dist} Summary: Nginx Brotli module Requires: nginx-ex = %{versionD}-%{release} %description module-brotli Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression. %package module-geoip2 Version: %{versionD}+%{module_geoip2} Release: 1%{?dist} Summary: Nginx GeoIP2 module BuildRequires: libmaxminddb-devel Requires: nginx-ex = %{versionD}-%{release} %description module-geoip2 Nginx GeoIP2 module - creates variables with values from the maxmind geoip2 databases based on the client IP (default) or from a specific variable (supports both IPv4 and IPv6) %package module-modsecurity Version: %{versionD}+%{module_modsecurity} Release: 1%{?dist} Summary: Nginx ModSecurity module BuildRequires: libmodsecurity-devel Requires: nginx-ex = %{versionD}-%{release} %description module-modsecurity ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx that is developed by Trustwave's SpiderLabs. It has a robust event-based programming language which provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring, logging and real-time analysis %package module-echo Version: %{versionD}+%{module_echo} Release: 1%{?dist} Summary: Nginx Echo module Requires: nginx-ex = %{versionD}-%{release} %description module-echo The Nginx Echo module wraps lots of Nginx internal APIs for streaming input and output, parallel/sequential subrequests, timers and sleeping, as well as various meta data accessing. %{summary}. Conflicts: nginx Provides: webserver Provides: nginx %description Nginx ("engine X") is a high-performance web and reverse proxy server created by Igor Sysoev. It can be used both as a standalone web server and as a proxy to reduce the load on back-end HTTP or mail servers. This package provides a version of nginx with the complete set of standard modules included. %prep %setup -q -n %{packagename}-%{versionD} mkdir modules %ifarch x86_64 tar -zxvf %{SOURCE101} -C modules/ tar -zxvf %{SOURCE102} -C modules/ngx_pagespeed-%{module_ps}-stable/ %endif tar -zxvf %{SOURCE103} -C modules/ tar -zxvf %{SOURCE104} -C modules/ tar -zxvf %{SOURCE105} -C modules/ tar -zxvf %{SOURCE106} -C modules/ tar -zxvf %{SOURCE107} -C modules/ tar -zxvf %{SOURCE108} -C modules/ tar -zxvf %{SOURCE109} -C modules/ tar -zxvf %{SOURCE110} -C modules/ tar -zxvf %{SOURCE111} -C modules/ %patch0 -p0 %patch1 -p1 %patch2 -p1 %build export DESTDIR=%{buildroot} ./configure \ --prefix=%{nginx_datadir} \ --sbin-path=%{_sbindir}/nginx \ --modules-path=%{_libdir}/nginx/modules \ --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_cache}/client_body \ --http-proxy-temp-path=%{nginx_home_cache}/proxy \ --http-fastcgi-temp-path=%{nginx_home_cache}/fastcgi \ --http-uwsgi-temp-path=%{nginx_home_cache}/uwsgi \ --http-scgi-temp-path=%{nginx_home_cache}/scgi \ --pid-path=%{_localstatedir}/run/nginx.pid \ --lock-path=%{_localstatedir}/run/nginx.lock \ --user=%{nginx_user} \ --group=%{nginx_group} \ --with-compat \ --with-file-aio \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_image_filter_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 \ %if 0%{?rhel} >= 7 --with-http_geoip_module \ %endif --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_xslt_module \ --with-http_v2_module \ --with-mail \ --with-mail_ssl_module \ --with-threads \ --with-stream \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-http_slice_module \ --with-stream_ssl_preread_module \ --with-debug \ --with-cc-opt="%{optflags} $(pcre-config --cflags) -DTCP_FASTOPEN=23" \ %if 0%{?rhel} <= 7 --with-cc="/opt/rh/devtoolset-%{gcc_version}/root/usr/bin/gcc" \ %endif --with-http_v2_hpack_enc \ --add-dynamic-module=modules/ngx_modsecurity-%{module_modsecurity} \ --add-dynamic-module=modules/ngx_headers_more-%{module_headers_more} \ --add-dynamic-module=modules/ngx_module_vts-%{module_vts} \ %ifarch x86_64 --add-dynamic-module=modules/ngx_pagespeed-%{module_ps}-stable \ %endif --add-dynamic-module=modules/ngx_brotli-%{module_brotli} \ --add-dynamic-module=modules/ngx_http_geoip2_module-%{module_geoip2} \ --add-dynamic-module=modules/ngx_echo-%{module_echo} \ --add-dynamic-module=modules/ngx_cache_purge-%{module_cache_purge} \ --add-dynamic-module=modules/ngx_dynamic_etag-%{module_dynamic_etag} \ --add-dynamic-module=modules/ngx_fancyindex-%{module_fancyindex} make %install make install DESTDIR=%{buildroot} 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 -iname '*.so' -exec chmod 0755 '{}' \; %{__mkdir} -p $RPM_BUILD_ROOT%{_libdir}/nginx/modules cd $RPM_BUILD_ROOT%{_sysconfdir}/nginx && \ %{__ln_s} ../..%{_libdir}/nginx/modules modules && cd - %if %{use_systemd} install -p -D -m 0644 %{SOURCE1} \ %{buildroot}%{_unitdir}/nginx.service %else install -p -D -m 0755 %{SOURCE2} \ %{buildroot}%{_initrddir}/nginx %endif install -p -D -m 0644 %{SOURCE3} \ %{buildroot}%{_sysconfdir}/logrotate.d/nginx install -p -d -m 0755 %{buildroot}%{nginx_confdir}/nginxconfig.io install -p -d -m 0755 %{buildroot}%{nginx_confdir}/sites-enabled install -p -d -m 0700 %{buildroot}%{nginx_home} install -p -d -m 0700 %{buildroot}%{nginx_home_cache} %ifarch x86_64 install -p -d -m 0700 %{buildroot}%{nginx_home_cache}/pagespeed %endif install -p -d -m 0700 %{buildroot}%{nginx_logdir} install -p -d -m 0755 %{buildroot}%{nginx_webroot} install -p -d -m 0755 %{buildroot}%{_datadir}/nginx/modules install -p -m 0644 %{SOURCE4} %{buildroot}%{nginx_confdir} install -p -m 0644 %{SOURCE10} %{SOURCE11} \ %{buildroot}%{nginx_confdir}/nginxconfig.io install -p -m 0644 %{SOURCE12} \ %{buildroot}%{nginx_confdir}/sites-enabled install -p -D -m 0644 %{_builddir}/nginx-%{versionD}/man/nginx.8 \ %{buildroot}%{_mandir}/man8/nginx.8 %if %{use_systemd} %{__mkdir} -p $RPM_BUILD_ROOT%{_libexecdir}/initscripts/legacy-actions/nginx %{__install} -m755 %SOURCE5 \ $RPM_BUILD_ROOT%{_libexecdir}/initscripts/legacy-actions/nginx/upgrade %{__install} -m755 %SOURCE6 \ $RPM_BUILD_ROOT%{_libexecdir}/initscripts/legacy-actions/nginx/check-reload %endif %ifarch x86_64 echo 'load_module "%{_libdir}/nginx/modules/ngx_pagespeed.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-pagespeed.conf %endif echo 'load_module "%{_libdir}/nginx/modules/ngx_http_headers_more_filter_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-headers-more.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_vhost_traffic_status_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-vts.conf echo -e 'load_module "%{_libdir}/nginx/modules/ngx_http_brotli_filter_module.so";\nload_module "%{_libdir}/nginx/modules/ngx_http_brotli_static_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-brotli.conf echo -e 'load_module "%{_libdir}/nginx/modules/ngx_http_geoip2_module.so";\nload_module "%{_libdir}/nginx/modules/ngx_stream_geoip2_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-geoip2.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_cache_purge_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-cache-purge.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_dynamic_etag_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-dynamic-etag.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_fancyindex_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-fancyindex.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_echo_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-echo.conf echo 'load_module "%{_libdir}/nginx/modules/ngx_http_modsecurity_module.so";' \ > %{buildroot}%{_datadir}/nginx/modules/module-modsecurity.conf %pre getent group %{nginx_group} > /dev/null || groupadd -r %{nginx_group} getent passwd %{nginx_user} > /dev/null || \ useradd -r -d %{nginx_home} -g %{nginx_group} \ -s /sbin/nologin -c "Nginx web server" %{nginx_user} exit 0 %post if [ $1 -eq 1 ]; then %if %{use_systemd} /usr/bin/systemctl preset nginx.service >/dev/null 2>&1 || : %else /sbin/chkconfig --add nginx %endif fi if [ $1 -eq 2 ]; then chmod 700 %{nginx_home} chmod 700 %{nginx_home_cache} chmod 700 %{nginx_logdir} fi if [ $1 -eq 1 ]; then cat </dev/null 2>&1 || : fi %endif %post module-headers-more if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-vts if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-brotli if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-geoip2 if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-cache-purge if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-dynamic-etag if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-fancyindex if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-echo if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %post module-modsecurity if [ $1 -eq 1 ]; then /usr/bin/systemctl reload nginx.service >/dev/null 2>&1 || : fi %preun if [ $1 -eq 0 ]; then %if %use_systemd /usr/bin/systemctl --no-reload disable nginx.service >/dev/null 2>&1 || : /usr/bin/systemctl stop nginx.service >/dev/null 2>&1 || : %else /sbin/service nginx stop > /dev/null 2>&1 /sbin/chkconfig --del nginx %endif fi %postun %if %use_systemd /usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||: %endif if [ $1 -ge 1 ]; then /sbin/service nginx status >/dev/null 2>&1 || exit 0 /sbin/service nginx upgrade >/dev/null 2>&1 || echo \ "Binary upgrade failed, please check nginx's error.log" fi %files %doc LICENSE CHANGES README %dir %{_datadir}/nginx %dir %{_datadir}/nginx/html %{_datadir}/nginx/html/* %{_sbindir}/nginx %{_mandir}/man8/nginx.8* %if %{use_systemd} %{_unitdir}/nginx.service %dir %{_libexecdir}/initscripts/legacy-actions/nginx %{_libexecdir}/initscripts/legacy-actions/nginx/* %else %{_initrddir}/nginx %endif %dir %{nginx_confdir} %dir %{nginx_confdir}/nginxconfig.io %dir %{nginx_confdir}/sites-enabled %{_sysconfdir}/nginx/modules %config(noreplace) %{nginx_confdir}/fastcgi.conf %config(noreplace) %{nginx_confdir}/fastcgi.conf.default %config(noreplace) %{nginx_confdir}/fastcgi_params %config(noreplace) %{nginx_confdir}/fastcgi_params.default %config(noreplace) %{nginx_confdir}/koi-utf %config(noreplace) %{nginx_confdir}/koi-win %config(noreplace) %{nginx_confdir}/mime.types %config(noreplace) %{nginx_confdir}/mime.types.default %config(noreplace) %{nginx_confdir}/nginx.conf %config(noreplace) %{nginx_confdir}/nginx.conf.default %config(noreplace) %{nginx_confdir}/scgi_params %config(noreplace) %{nginx_confdir}/scgi_params.default %config(noreplace) %{nginx_confdir}/uwsgi_params %config(noreplace) %{nginx_confdir}/uwsgi_params.default %config(noreplace) %{nginx_confdir}/win-utf %config(noreplace) %{nginx_confdir}/nginxconfig.io/*.conf %config(noreplace) %{nginx_confdir}/sites-enabled/*.conf %config(noreplace) %{_sysconfdir}/logrotate.d/nginx %attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_home} %attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_home_cache} %ifarch x86_64 %attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_home_cache}/pagespeed %endif %attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_logdir} %attr(0755,root,root) %dir %{_libdir}/nginx %attr(0755,root,root) %dir %{_libdir}/nginx/modules %attr(0755,root,root) %dir %{_datadir}/nginx/modules %{nginx_confdir}/nginxconfig.io/*.conf %{nginx_confdir}/sites-enabled/*.conf %ifarch x86_64 %files module-pagespeed %{_datadir}/nginx/modules/module-pagespeed.conf %{_libdir}/nginx/modules/ngx_pagespeed.so %endif %files module-headers-more %{_datadir}/nginx/modules/module-headers-more.conf %{_libdir}/nginx/modules/ngx_http_headers_more_filter_module.so %files module-vts %{_datadir}/nginx/modules/module-vts.conf %{_libdir}/nginx/modules/ngx_http_vhost_traffic_status_module.so %files module-brotli %{_datadir}/nginx/modules/module-brotli.conf %{_libdir}/nginx/modules/ngx_http_brotli_filter_module.so %{_libdir}/nginx/modules/ngx_http_brotli_static_module.so %files module-geoip2 %{_datadir}/nginx/modules/module-geoip2.conf %{_libdir}/nginx/modules/ngx_http_geoip2_module.so %{_libdir}/nginx/modules/ngx_stream_geoip2_module.so %files module-cache-purge %{_datadir}/nginx/modules/module-cache-purge.conf %{_libdir}/nginx/modules/ngx_http_cache_purge_module.so %files module-fancyindex %{_datadir}/nginx/modules/module-fancyindex.conf %{_libdir}/nginx/modules/ngx_http_fancyindex_module.so %files module-dynamic-etag %{_datadir}/nginx/modules/module-dynamic-etag.conf %{_libdir}/nginx/modules/ngx_http_dynamic_etag_module.so %files module-echo %{_datadir}/nginx/modules/module-echo.conf %{_libdir}/nginx/modules/ngx_http_echo_module.so %files module-modsecurity %{_datadir}/nginx/modules/module-modsecurity.conf %{_libdir}/nginx/modules/ngx_http_modsecurity_module.so %changelog * Sat Feb 19 2022 Alan Miao - 1.20.2-1 - Initialization