Skip to content

Commit 952e3c0

Browse files
authored
Merge pull request #7 from LePresidente/master
Added both lua-resty-http lua plugin and Crowdsec-Openresty-Bouncer
2 parents 7254ad5 + 7aa8137 commit 952e3c0

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

.jenkins/Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pipeline {
1616
BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('/', '-')}"
1717
// Software versions; OpenResty does not support Lua >= 5.2
1818
OPENRESTY_VERSION = '1.19.9.1'
19+
CROWDSEC_OPENRESTY_BOUNCER_VERSION = '0.1.7'
1920
LUA_VERSION = '5.1.5'
2021
LUAROCKS_VERSION = '3.3.1'
2122
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The following images are built:
2222
**latest**
2323
- OpenResty
2424
- Lua
25+
- [Crowdsec Openresty Bouncer](https://github.com/crowdsecurity/cs-openresty-bouncer)
2526

2627
**certbot**
2728
- Certbot

docker/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ RUN apt-get update \
5757
tzdata \
5858
unzip \
5959
zlib1g \
60+
gettext \
61+
wget \
6062
&& apt-get clean \
6163
&& rm -rf /var/lib/apt/lists/* \
6264
&& rm -rf /var/cache/* /var/log/* /tmp/* /var/lib/dpkg/status-old
@@ -72,16 +74,22 @@ COPY ./scripts/install-lua /tmp/install-lua
7274
COPY --from=nginxbuilder /tmp/openresty /tmp/openresty
7375
COPY ./scripts/install-openresty /tmp/install-openresty
7476

77+
# Copy crowdsec openresty bouncer install script
78+
COPY ./scripts/install-crowdsec_openresty_bouncer /tmp/install-crowdsec_openresty_bouncer
79+
7580
ARG OPENRESTY_VERSION
81+
ARG CROWDSEC_OPENRESTY_BOUNCER_VERSION
7682
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
77-
OPENRESTY_VERSION=${OPENRESTY_VERSION}
83+
OPENRESTY_VERSION=${OPENRESTY_VERSION} \
84+
CROWDSEC_OPENRESTY_BOUNCER_VERSION=${CROWDSEC_OPENRESTY_BOUNCER_VERSION}
7885

7986
# Install openresty, lua, then clean up file system
8087
RUN apt-get update \
8188
&& apt-get install -y gcc make socat git \
8289
&& /tmp/install-lua \
8390
&& /tmp/install-openresty \
84-
&& apt-get remove -y make gcc git \
91+
&& /tmp/install-crowdsec_openresty_bouncer \
92+
&& apt-get remove -y make gcc git wget gettext \
8593
&& apt-get autoremove -y \
8694
&& apt-get clean \
8795
&& rm -rf /var/lib/apt/lists/* \

local-build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RESET='\E[0m'
99
DOCKER_IMAGE=nginxproxymanager/nginx-full
1010

1111
export OPENRESTY_VERSION=1.19.9.1
12+
export CROWDSEC_OPENRESTY_BOUNCER_VERSION=0.1.7
1213
export LUA_VERSION=5.1.5
1314
export LUAROCKS_VERSION=3.3.1
1415

@@ -18,6 +19,7 @@ echo -e "${BLUE}❯ ${CYAN}Building ${YELLOW}latest ${CYAN}...${RESET}"
1819
docker build \
1920
--pull \
2021
--build-arg OPENRESTY_VERSION \
22+
--build-arg CROWDSEC_OPENRESTY_BOUNCER_VERSION \
2123
--build-arg LUA_VERSION \
2224
--build-arg LUAROCKS_VERSION \
2325
-t ${DOCKER_IMAGE}:latest \

scripts/buildx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ docker buildx build \
2525
--build-arg OPENRESTY_VERSION \
2626
--build-arg LUA_VERSION \
2727
--build-arg LUAROCKS_VERSION \
28+
--build-arg CROWDSEC_OPENRESTY_BOUNCER_VERSION \
2829
$@ \
2930
.
3031

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash -e
2+
3+
BLUE='\E[1;34m'
4+
CYAN='\E[1;36m'
5+
YELLOW='\E[1;33m'
6+
GREEN='\E[1;32m'
7+
RED='\E[1;31m'
8+
RESET='\E[0m'
9+
10+
echo -e "${BLUE}${CYAN}Installing Crowdsec OpenResty Bouncer ${YELLOW}${CROWDSEC_OPENRESTY_BOUNCER_VERSION:-}...${RESET}"
11+
12+
if [ "${CROWDSEC_OPENRESTY_BOUNCER_VERSION:-}" = "" ]; then
13+
echo -e "${RED}❯ ERROR: CROWDSEC_OPENRESTY_BOUNCER_VERSION environment variable is not set!${RESET}"
14+
exit 1
15+
fi
16+
17+
cd /tmp
18+
wget "https://github.com/crowdsecurity/cs-openresty-bouncer/releases/download/v${CROWDSEC_OPENRESTY_BOUNCER_VERSION}/crowdsec-openresty-bouncer.tgz"
19+
mkdir -p /tmp/crowdsec
20+
tar xzf crowdsec-openresty-bouncer.tgz --strip 1 -C /tmp/crowdsec
21+
rm -rf /tmp/crowdsec-openresty-bouncer.tgz
22+
cd /tmp/crowdsec
23+
24+
bash ./install.sh --NGINX_CONF_DIR=/etc/nginx/conf.d --LIB_PATH=/etc/nginx/lualib --CONFIG_PATH=/defaults/crowdsec --DATA_PATH=/defaults/crowdsec --docker
25+
sed -i 's|ENABLED=.*|ENABLED=false|' /defaults/crowdsec/crowdsec-openresty-bouncer.conf
26+
rm -rf /tmp/crowdsec
27+
28+
echo -e "${BLUE}${GREEN}OpenResty plugins install completed${RESET}"

scripts/install-openresty

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ echo -e "${BLUE}❯ ${CYAN}Installing OpenResty plugins...${RESET}"
1919
cd /
2020
luarocks install lua-cjson
2121
luarocks install lua-resty-openidc
22+
luarocks install lua-resty-http
2223

2324
echo -e "${BLUE}${GREEN}OpenResty plugins install completed${RESET}"

0 commit comments

Comments
 (0)