File nginx-module-sticky-ng.spec of Package nginx-module-sticky-ng

# spec file for package nginx-module-sticky-ng
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%if 0%{?suse_version} != 1315 || 0%{?is_opensuse}
%bcond_without libatomic
%bcond_with    libatomic

%if 0%{?suse_version} > 1220
%bcond_without pcre_jit
%bcond_with    pcre_jit

%define commit 08a395c66e42
%define shortcommit %(c=%{commit}; echo ${c:0:7})
%define project_name nginx-sticky-module-ng
%define nginx_moduledir %{_libdir}/nginx/modules

Name:           nginx-module-sticky-ng
Version:        0.0.0+git08092016.%{shortcommit}
Release:        0
Summary:        Nginx module to add a sticky cookie to be forwarded to the same upstream server
License:        BSD-2-Clause
Group:          Productivity/Networking/Web/Proxy
Url:  {project_name}
Patch0:         dynamic-module.patch
Patch1:         openssl-headers.patch
BuildRequires:  libopenssl-devel
BuildRequires:  nginx-source
BuildRequires:  pcre-devel
%if %{with libatomic}
BuildRequires:  libatomic-ops-devel
Requires:       nginx = %(rpm -q nginx-source | rev | cut -d. --complement -f1 | cut -d"-" -f2 | rev)

A nginx module to add a sticky cookie to be always forwarded to the same
upstream server.

When dealing with several backend servers, it's sometimes useful that one
client (browser) is always served by the same backend server (for session
persistance for example). A cookie is used to track the upstream server, since
balancing just by IP address, behind which multiple clients may live, can be
unfair to the load balancing.

The Sticky module can't apply when cookies are not supported by the browser.
When the sticky module can't apply, it switchs back to the classic Round Robin
Upstream or returns a "Bad Gateway" (depending on the no_fallback flag).

mkdir %{project_name}
tar -xzf %{SOURCE0} --strip-components=1 -C %{project_name}
patch -p1 -d %{project_name} < %{PATCH0}
patch -p1 -d %{project_name} < %{PATCH1}
cp -r /usr/src/nginx .

cd nginx
# configure macro cannot be used, because this configure script doesn't
# accept some options provided by the macro (like i.e. --host).
./configure                                    \
  --user=nginx --group=nginx                   \
  --without-select_module                      \
  --without-poll_module                        \
  --without-http_gzip_module                   \
  --with-threads                               \
  --with-file-aio                              \
  --with-ipv6                                  \
  --with-pcre                                  \
  %if %{with pcre_jit}
  --with-pcre-jit                              \
  %if %{with libatomic}
  --with-libatomic                             \
  --with-compat                                \
  --add-dynamic-module=../%{project_name}      \
%if 0%{?suse_version} > 1220
  --with-cc-opt="%{optflags} -fPIC -D_GNU_SOURCE -std=gnu99 -fstack-protector" \
  --with-ld-opt="-Wl,-z,relro,-z,now -pie"
make modules

mkdir -p %{buildroot}%{nginx_moduledir}
install -D -m 0644 nginx/objs/ %{buildroot}%{nginx_moduledir}

%license %{project_name}/LICENSE
%dir %{_libdir}/nginx
%dir %{nginx_moduledir}

openSUSE Build Service is sponsored by