Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN cp lua-cs-bouncer/config_example.conf /etc/crowdsec/bouncers/crowdsec-openre
RUN rm -rf ./lua-cs-bouncer/
COPY ./openresty /tmp
RUN SSL_CERTS_PATH=/etc/ssl/certs/ca-certificates.crt envsubst < /tmp/crowdsec_openresty.conf > /etc/nginx/conf.d/crowdsec_openresty.conf
RUN sed -i '1 i\resolver local=on ipv6=off;' /etc/nginx/conf.d/crowdsec_openresty.conf
COPY ./docker/docker_start.sh /

ENTRYPOINT /bin/bash docker_start.sh
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ do
--DATA_PATH=*)
DATA_PATH="${1#*=}"
;;
--SSL_CERTS_PATH=*)
SSL_CERTS_PATH="${1#*=}"
;;
-y|--yes)
SILENT="true"
;;
Expand Down Expand Up @@ -149,14 +152,11 @@ check_lua_dependency() {

install() {
mkdir -p "${DATA_PATH}/templates/"

cp -r lua/lib/* "${LIB_PATH}/"
cp templates/* "${DATA_PATH}/templates/"
#Patch the nginx config file
SSL_CERTS_PATH=${SSL_CERTS_PATH} envsubst < openresty/${NGINX_CONF} > "${NGINX_CONF_DIR}/${NGINX_CONF}"
sed -i 's|/etc/crowdsec/bouncers|'"${CONFIG_PATH}"'|' "${NGINX_CONF_DIR}/${NGINX_CONF}"
#Some docker images like Nginx Proxy Manager has this defined already.
[ -z ${DOCKER} ] || sed -i 's|resolver local=on ipv6=off;||' "${NGINX_CONF_DIR}/${NGINX_CONF}"
}


Expand Down
7 changes: 6 additions & 1 deletion openresty/crowdsec_openresty.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
lua_package_path '$prefix/../lualib/plugins/crowdsec/?.lua;;';
lua_shared_dict crowdsec_cache 50m;
lua_ssl_trusted_certificate ${SSL_CERTS_PATH};

init_by_lua_block {
cs = require "crowdsec"
local ok, err = cs.init("/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf", "crowdsec-openresty-bouncer/v0.1.10")
if ok == nil then
ngx.log(ngx.ERR, "[Crowdsec] " .. err)
error()
end
ngx.log(ngx.ALERT, "[Crowdsec] Initialisation done")
if ok == "Disabled" then
ngx.log(ngx.ALERT, "[Crowdsec] Bouncer Disabled")
else
ngx.log(ngx.ALERT, "[Crowdsec] Initialisation done")
end
}

access_by_lua_block {
Expand Down