From 760327070037208e163ee4776fe3fbd52a608c7f Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 10 Sep 2024 14:08:22 +0200 Subject: [PATCH 1/4] CI: Upgrade nginx to version 1.27.1 --- .github/workflows/ci.yml | 2 +- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04651e2..5eecc6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: matrix: include: - os: ubuntu-22.04 - nginx-version: 1.25.3 + nginx-version: 1.27.1 steps: - uses: actions/checkout@v4 - name: Install dependencies diff --git a/README.md b/README.md index 29988e2..432c2c4 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ location = /quota { You can install this module manually by recompiling the standard Nginx core as follows: -1. Grab the nginx source code from [nginx.org](http://nginx.org) (this module is tested on version 1.25.3). +1. Grab the nginx source code from [nginx.org](https://nginx.org) (this module is tested on version 1.27.1). 2. Clone this repository into a newly created directory (for e.g. `./rate-limit-nginx-module`) 3. Build the nginx source with this module: ```bash -wget https://nginx.org/download/nginx-1.25.3.tar.gz -tar -xzvf nginx-1.25.3.tar.gz -cd nginx-1.25.3/ +wget https://nginx.org/download/nginx-1.27.1.tar.gz +tar -xzvf nginx-1.27.1.tar.gz +cd nginx-1.27.1/ git clone https://github.com/weserv/rate-limit-nginx-module rate-limit-nginx-module From fed4979560fc89c38bd4ecd9e22ced87e527a520 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 10 Sep 2024 14:08:57 +0200 Subject: [PATCH 2/4] CI: Upgrade runner to Ubuntu 24.04 --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5eecc6a..9424679 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: fail-fast: true matrix: include: - - os: ubuntu-22.04 + - os: ubuntu-24.04 nginx-version: 1.27.1 steps: - uses: actions/checkout@v4 @@ -32,10 +32,10 @@ jobs: - name: Load Redis rate limiter module run: | # Redis < 7 - redis-cli MODULE LOAD /usr/lib/redis/modules/ratelimit.so + # redis-cli MODULE LOAD /usr/lib/redis/modules/ratelimit.so # Redis >= 7 (due to `enable-module-command no` restriction) - # echo "loadmodule /usr/lib/redis/modules/ratelimit.so" | sudo tee -a /etc/redis/redis.conf - # sudo service redis-server restart + echo "loadmodule /usr/lib/redis/modules/ratelimit.so" | sudo tee -a /etc/redis/redis.conf + sudo service redis-server restart - name: Prepare environment run: echo "$HOME/nginx/sbin" >> $GITHUB_PATH - name: Run integration tests From 970190e37835f2f8b99537f7119f4f14cddb47b4 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 19 Jan 2025 11:12:41 +0100 Subject: [PATCH 3/4] CI: Cleanup configuration --- .github/workflows/ci.yml | 37 ++++++++++++++++++++++++++++++------- ci/build-rate-limiter.sh | 14 -------------- ci/install-nginx.sh | 22 ---------------------- 3 files changed, 30 insertions(+), 43 deletions(-) delete mode 100755 ci/build-rate-limiter.sh delete mode 100755 ci/install-nginx.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9424679..4312e4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,16 +1,25 @@ name: CI + on: [ push, pull_request, workflow_dispatch ] + +permissions: {} + jobs: CI: runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: true matrix: include: - os: ubuntu-24.04 nginx-version: 1.27.1 + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install dependencies run: | # for Test::Nginx @@ -18,17 +27,29 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/openresty.gpg] https://openresty.org/package/ubuntu $(lsb_release -sc) main" | \ sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null sudo apt-get update - sudo apt-get install libtest-nginx-perl redis-server + sudo apt-get install --no-install-recommends libtest-nginx-perl redis-server + - name: Install nginx env: NGINX_VERSION: ${{ matrix.nginx-version }} - run: ci/install-nginx.sh --add-module=$GITHUB_WORKSPACE/ - - name: Build Redis rate limiter module - run: ci/build-rate-limiter.sh + working-directory: ${{ runner.temp }} + run: | + mkdir nginx + curl -Ls https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | \ + tar xzC nginx --strip-components=1 + cd nginx + ./configure --prefix="$HOME/nginx" --add-module=${{ github.workspace }} + make -j$(nproc) + make install + - name: Install Redis rate limiter module + working-directory: ${{ runner.temp }} run: | - sudo mkdir -p /usr/lib/redis/modules - sudo mv rate-limiter/ratelimit.so /usr/lib/redis/modules/ + git clone https://github.com/onsigntv/redis-rate-limiter.git + cd redis-rate-limiter + make -j$(nproc) USE_MONOTONIC_CLOCK=1 + sudo install -D -t /usr/lib/redis/modules ratelimit.so + - name: Load Redis rate limiter module run: | # Redis < 7 @@ -36,7 +57,9 @@ jobs: # Redis >= 7 (due to `enable-module-command no` restriction) echo "loadmodule /usr/lib/redis/modules/ratelimit.so" | sudo tee -a /etc/redis/redis.conf sudo service redis-server restart + - name: Prepare environment run: echo "$HOME/nginx/sbin" >> $GITHUB_PATH + - name: Run integration tests run: prove -r t diff --git a/ci/build-rate-limiter.sh b/ci/build-rate-limiter.sh deleted file mode 100755 index 44f5ccf..0000000 --- a/ci/build-rate-limiter.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# Exit immediately if a command exits with a non-zero status -set -e - -# Define variables -branch=master -rate_limiter_repo=https://github.com/onsigntv/redis-rate-limiter.git - -echo "Building redis-rate-limiter from source" - -git clone -b $branch --single-branch $rate_limiter_repo rate-limiter -cd rate-limiter -make -j$(nproc) USE_MONOTONIC_CLOCK=1 diff --git a/ci/install-nginx.sh b/ci/install-nginx.sh deleted file mode 100755 index 7a74f4d..0000000 --- a/ci/install-nginx.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Exit immediately if a command exits with a non-zero status -set -e - -# Define variables -version=$NGINX_VERSION -nginx_tarball=https://nginx.org/download/nginx-$version.tar.gz - -# Make sure the nginx folder exist -mkdir -p "$HOME/nginx" - -echo "Installing nginx $version" - -curl -Ls $nginx_tarball | tar xz -cd nginx-$version -./configure --prefix="$HOME/nginx" "$@" -make -j$(nproc) && make install - -# Clean-up build directory -cd ../ -rm -rf nginx-$version From 0dca5d59ed830958cd4ec1c8844fb3454b68d988 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 19 Jan 2025 11:16:16 +0100 Subject: [PATCH 4/4] CI: Upgrade nginx to version 1.27.3 --- .github/workflows/ci.yml | 2 +- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4312e4d..ff1ffe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: matrix: include: - os: ubuntu-24.04 - nginx-version: 1.27.1 + nginx-version: 1.27.3 steps: - name: Checkout repository diff --git a/README.md b/README.md index 432c2c4..1a8d25d 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ location = /quota { You can install this module manually by recompiling the standard Nginx core as follows: -1. Grab the nginx source code from [nginx.org](https://nginx.org) (this module is tested on version 1.27.1). +1. Grab the nginx source code from [nginx.org](https://nginx.org) (this module is tested on version 1.27.3). 2. Clone this repository into a newly created directory (for e.g. `./rate-limit-nginx-module`) 3. Build the nginx source with this module: ```bash -wget https://nginx.org/download/nginx-1.27.1.tar.gz -tar -xzvf nginx-1.27.1.tar.gz -cd nginx-1.27.1/ +wget https://nginx.org/download/nginx-1.27.3.tar.gz +tar -xzvf nginx-1.27.3.tar.gz +cd nginx-1.27.3/ git clone https://github.com/weserv/rate-limit-nginx-module rate-limit-nginx-module