Hi,
I'm trying to set up the nginx bouncer with recaptcha support on Ubuntu 24.04 LTS. Despite having new enough versions (according to #44) I am unable to get it to work with HTTP2 connections. The first connection to the server shows the captcha as expected, but if you refresh the page it will change to a 500 error, with the log:
2025/10/16 17:03:18 [error] 23#23: *15 lua entry thread aborted: runtime error: /usr/lib/crowdsec/lua/crowdsec.lua:653: http2 requests are not supported without content-length header
stack traceback:
coroutine 0:
[C]: in function 'read_body'
/usr/lib/crowdsec/lua/crowdsec.lua:653: in function 'Allow'
access_by_lua(conf.d/crowdsec_nginx.conf:20):6: in main chunk, client: 172.17.0.1, server: _, request: "HEAD / HTTP/2.0", host: "127.0.0.1:8444"
Incidentally I get the same error in both live and stream modes. As the error seems to be coming from the lua code, I am raising it here instead of against cs-nginx-bouncer but let me know if it should be raised there instead.
To reproduce:
Dockerfile (replace the keys as appropriate):
FROM ubuntu:noble
RUN apt-get update && \
apt-get -y install nginx lua5.1 libnginx-mod-http-lua luarocks gettext-base lua-cjson curl mc net-tools
RUN curl -s https://install.crowdsec.net | sh
RUN apt-get -y install crowdsec || true
RUN bash -c "crowdsec &"
RUN apt-get -y install crowdsec-nginx-bouncer || true
RUN apt-get -y install ssl-cert || true
RUN sed -i 's|^CAPTCHA_PROVIDER=$|CAPTCHA_PROVIDER=recaptcha|' /etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf
RUN sed -i 's|^SITE_KEY=$|SITE_KEY=<SITE KEY HERE>|' /etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf
RUN sed -i 's|^SECRET_KEY=$|SECRET_KEY=<SECRET KEY HERE>|' /etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf
RUN sed -i '/^lua_ssl_trusted_certificate/ i \resolver 8.8.8.8 ipv6=off;' /etc/nginx/conf.d/crowdsec_nginx.conf
RUN sed -i 's|# listen 443 ssl default_server;|listen 443 ssl default_server http2;|' /etc/nginx/sites-available/default
RUN sed -i 's|# listen \[::\]:443 ssl default_server;|listen [::]:443 ssl default_server http2;|' /etc/nginx/sites-available/default
RUN sed -i 's|# include snippets/snakeoil.conf;|include snippets/snakeoil.conf;|' /etc/nginx/sites-available/default
RUN echo 'error_log /dev/stdout debug;' >> /etc/nginx/nginx.conf
RUN cat <<EOF > /opt/start.sh
#!/bin/bash
crowdsec & nginx -g "daemon off;"
EOF
RUN chmod +x /opt/start.sh
CMD ["/opt/start.sh"]
Commands to build and run the container:
docker build -t nginx-cs-test .
docker run -d --name nginx-cs-test -p 8444:443 nginx-cs-test
docker exec -i nginx-cs-test cscli decisions add -r 172.16.0.0/12 -t captcha
Demonstrating the problem:
$ curl -sIk --http2 https://127.0.0.1:8444/
HTTP/2 200
server: nginx/1.24.0 (Ubuntu)
date: Thu, 16 Oct 2025 17:03:00 GMT
content-type: text/html
cache-control: no-cache
$ curl -sIk --http2 https://127.0.0.1:8444/
HTTP/2 500
server: nginx/1.24.0 (Ubuntu)
date: Thu, 16 Oct 2025 17:03:18 GMT
content-type: text/html
content-length: 186
$
Versions:
$ docker exec nginx-cs-test dpkg -l *nginx* | grep ^ii
ii crowdsec-nginx-bouncer 1.1.3 all lua-based nginx bouncer for Crowdsec
ii libnginx-mod-http-lua 1:0.10.26-2 amd64 Lua module for Nginx
ii libnginx-mod-http-ndk 1:0.3.3-1build1 amd64 Nginx Development Kit module
ii nginx 1.24.0-2ubuntu7.5 amd64 small, powerful, scalable web/proxy server
ii nginx-common 1.24.0-2ubuntu7.5 all small, powerful, scalable web/proxy server - common files
I have uploded the nginx debug log output to https://gist.github.com/ngreatorex/fe77d5dec4eac7bf9a077247af21d1d5
Hi,
I'm trying to set up the nginx bouncer with recaptcha support on Ubuntu 24.04 LTS. Despite having new enough versions (according to #44) I am unable to get it to work with HTTP2 connections. The first connection to the server shows the captcha as expected, but if you refresh the page it will change to a 500 error, with the log:
Incidentally I get the same error in both live and stream modes. As the error seems to be coming from the lua code, I am raising it here instead of against cs-nginx-bouncer but let me know if it should be raised there instead.
To reproduce:
Dockerfile (replace the keys as appropriate):
Commands to build and run the container:
Demonstrating the problem:
Versions:
I have uploded the nginx debug log output to https://gist.github.com/ngreatorex/fe77d5dec4eac7bf9a077247af21d1d5