Skip to content

Instantly share code, notes, and snippets.

@zypA13510
Last active December 29, 2021 10:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zypA13510/2d72a3e918e262ff4a885295560cfe32 to your computer and use it in GitHub Desktop.
Save zypA13510/2d72a3e918e262ff4a885295560cfe32 to your computer and use it in GitHub Desktop.
%global origname traffic-accounting-nginx-module
%global commitref d53a4a6
Name: nginx-mod-traffic-accounting
Version: 2.0
Release: 2.git.106.d53a4a6%{?dist}
Summary: nginx traffic accounting module
License: BSD
URL: https://github.com/Lax/traffic-accounting-nginx-module
Source0: %{url}/archive/%{commitref}/%{origname}-%{version}.tar.gz
Requires: nginx-mod-http-accounting
#Requires: nginx-mod-stream-accounting
BuildRequires: gcc
BuildRequires: nginx-mod-devel
%description
Monitor the incoming and outgoing traffic metrics in realtime for NGINX.
%package -n nginx-mod-http-accounting
Summary: Nginx HTTP accounting module
%description -n nginx-mod-http-accounting
%{summary}.
#%package -n nginx-mod-stream-accounting
#Summary: Nginx stream accounting module
#Requires: nginx-mod-stream
#
#%description -n nginx-mod-stream-accounting
#%{summary}.
%prep
%autosetup -n %{origname}-%{version}
%build
%nginx_modconfigure
#%nginx_modconfigure --with-stream
%nginx_modbuild
%install
pushd %{_vpath_builddir}
install -dm 0755 %{buildroot}%{nginx_moddir}
install -pm 0755 ngx_http_accounting_module.so %{buildroot}%{nginx_moddir}
#install -pm 0755 ngx_stream_accounting_module.so %{buildroot}%{nginx_moddir}
install -dm 0755 %{buildroot}%{nginx_modconfdir}
echo 'load_module "%{nginx_moddir}/ngx_http_accounting_module.so";' \
> %{buildroot}%{nginx_modconfdir}/mod-http-accounting.conf
#echo 'load_module "%{nginx_moddir}/ngx_stream_accounting_module.so";' \
# > %{buildroot}%{nginx_modconfdir}/mod-stream-accounting.conf
popd
%files
%license LICENSE
%doc README.md
%files -n nginx-mod-http-accounting
%license LICENSE
%{nginx_moddir}/ngx_http_accounting_module.so
%{nginx_modconfdir}/mod-http-accounting.conf
#%files -n nginx-mod-stream-accounting
#%license LICENSE
#%{nginx_moddir}/ngx_stream_accounting_module.so
#%{nginx_modconfdir}/mod-stream-accounting.conf
@zypA13510
Copy link
Author

Works on copr, albeit with some limitations:

  • Only builds on Fedora 33+ due to difference in the build process of NGINX base package (specifically, whether they produce mod-devel package or not).
  • Only building http module, i.e. stream is not built, because I can't figure out how to configure $STREAM to 'YES' or 'DYNAMIC' in the build environment (the base package was built with --with-stream=dynamic but somehow not working12 when building modules). The related sections are kept in the spec file as comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment