Skip to content

Commit 10eec3b

Browse files
fix: update HAProxy config paths and header names (#110)
* fix: update HAProxy config paths and header names Update HAProxy configuration files to use standardized paths and canonical header names: - Fix setenv paths from /var/lib/crowdsec/lua/haproxy/templates/ to /var/lib/crowdsec-haproxy-spoa-bouncer/html/ to match Debian/RPM/Docker packaging - Update header names from X-CrowdSec-* to X-Crowdsec-* (canonical form) This ensures consistency across all deployment methods. * fix: update Dockerfile paths to match standardized locations Update Dockerfile to use the same standardized paths as Debian/RPM packaging: - Lua files: /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/ - Templates: /var/lib/crowdsec-haproxy-spoa-bouncer/html/ This ensures consistency across all deployment methods (Docker, Debian, RPM). * fix: update docker-compose volume mount paths Update volume mount paths in docker-compose files to match standardized locations: - Templates: /var/lib/crowdsec-haproxy-spoa-bouncer/html/ - Lua files: /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/ This ensures consistency with Dockerfile, Debian, and RPM packaging.
1 parent d38678c commit 10eec3b

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ RUN addgroup -S crowdsec-spoa && adduser -S -D -H -s /sbin/nologin -g crowdsec-s
2626
## Create a socket for the spoa to inherit crowdsec-spoa:haproxy user from official haproxy image
2727
RUN mkdir -p /run/crowdsec-spoa/ && chown crowdsec-spoa:haproxy /run/crowdsec-spoa/ && chmod 770 /run/crowdsec-spoa/
2828

29-
## Copy templates
30-
RUN mkdir -p /var/lib/crowdsec/lua/haproxy/templates/
31-
COPY --from=build /go/src/cs-spoa-bouncer/templates/* /var/lib/crowdsec/lua/haproxy/templates/
29+
## Copy Lua files (matching Debian/RPM paths)
30+
RUN mkdir -p /usr/lib/crowdsec-haproxy-spoa-bouncer/lua
31+
COPY --from=build /go/src/cs-spoa-bouncer/lua/* /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/
3232

33-
RUN mkdir -p /usr/local/crowdsec/lua/haproxy/
34-
COPY --from=build /go/src/cs-spoa-bouncer/lua/* /usr/local/crowdsec/lua/haproxy/
33+
## Copy templates (matching Debian/RPM paths)
34+
RUN mkdir -p /var/lib/crowdsec-haproxy-spoa-bouncer/html
35+
COPY --from=build /go/src/cs-spoa-bouncer/templates/* /var/lib/crowdsec-haproxy-spoa-bouncer/html/
3536

36-
RUN chown -R root:haproxy /var/lib/crowdsec/lua/haproxy /usr/local/crowdsec/lua/haproxy
37+
RUN chown -R root:haproxy /usr/lib/crowdsec-haproxy-spoa-bouncer/lua /var/lib/crowdsec-haproxy-spoa-bouncer/html
3738

38-
VOLUME [ "/usr/local/crowdsec/lua/haproxy/", "/var/lib/crowdsec/lua/haproxy/templates/" ]
39+
VOLUME [ "/usr/lib/crowdsec-haproxy-spoa-bouncer/lua/", "/var/lib/crowdsec-haproxy-spoa-bouncer/html/" ]
3940

4041
RUN chmod +x /docker_start.sh
4142

config/haproxy-upstreamproxy.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ global
66
log stdout format raw local0
77
lua-prepend-path /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/?.lua
88
lua-load /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/crowdsec.lua
9-
setenv CROWDSEC_BAN_TEMPLATE_PATH /var/lib/crowdsec/lua/haproxy/templates/ban.html
10-
setenv CROWDSEC_CAPTCHA_TEMPLATE_PATH /var/lib/crowdsec/lua/haproxy/templates/captcha.html
9+
setenv CROWDSEC_BAN_TEMPLATE_PATH /var/lib/crowdsec-haproxy-spoa-bouncer/html/ban.html
10+
setenv CROWDSEC_CAPTCHA_TEMPLATE_PATH /var/lib/crowdsec-haproxy-spoa-bouncer/html/captcha.html
1111

1212
defaults
1313
log global
@@ -41,9 +41,9 @@ frontend test
4141
# tcp-request content reject if { var(txn.crowdsec.remediation) -m str "ban" }
4242

4343
## Set a custom header on the request for upstream services to use
44-
http-request set-header X-CrowdSec-Remediation %[var(txn.crowdsec.remediation)] if { var(txn.crowdsec.remediation) -m found }
44+
http-request set-header X-Crowdsec-Remediation %[var(txn.crowdsec.remediation)] if { var(txn.crowdsec.remediation) -m found }
4545
## Set a custom header on the request for upstream services to use
46-
http-request set-header X-CrowdSec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
46+
http-request set-header X-Crowdsec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
4747

4848
## Handle 302 redirect for successful captcha validation (native HAProxy redirect)
4949
http-request redirect code 302 location %[var(txn.crowdsec.redirect)] if { var(txn.crowdsec.remediation) -m str "allow" } { var(txn.crowdsec.redirect) -m found }

config/haproxy.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ global
33
log stdout format raw local0
44
lua-prepend-path /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/?.lua
55
lua-load /usr/lib/crowdsec-haproxy-spoa-bouncer/lua/crowdsec.lua
6-
setenv CROWDSEC_BAN_TEMPLATE_PATH /var/lib/crowdsec/lua/haproxy/templates/ban.html
7-
setenv CROWDSEC_CAPTCHA_TEMPLATE_PATH /var/lib/crowdsec/lua/haproxy/templates/captcha.html
6+
setenv CROWDSEC_BAN_TEMPLATE_PATH /var/lib/crowdsec-haproxy-spoa-bouncer/html/ban.html
7+
setenv CROWDSEC_CAPTCHA_TEMPLATE_PATH /var/lib/crowdsec-haproxy-spoa-bouncer/html/captcha.html
88

99
defaults
1010
log global
@@ -31,9 +31,9 @@ frontend test
3131
# tcp-request content reject if { var(txn.crowdsec.remediation) -m str "ban" }
3232

3333
## Set a custom header on the request for upstream services to use
34-
http-request set-header X-CrowdSec-Remediation %[var(txn.crowdsec.remediation)] if { var(txn.crowdsec.remediation) -m found }
34+
http-request set-header X-Crowdsec-Remediation %[var(txn.crowdsec.remediation)] if { var(txn.crowdsec.remediation) -m found }
3535
## Set a custom header on the request for upstream services to use
36-
http-request set-header X-CrowdSec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
36+
http-request set-header X-Crowdsec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
3737

3838
## Handle 302 redirect for successful captcha validation (native HAProxy redirect)
3939
http-request redirect code 302 location %[var(txn.crowdsec.redirect)] if { var(txn.crowdsec.remediation) -m str "allow" } { var(txn.crowdsec.redirect) -m found }

docker-compose.proxy-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ services:
88
- crowdsec
99
volumes:
1010
- sockets:/run/
11-
- templates:/var/lib/crowdsec/lua/haproxy/templates/
12-
- lua:/usr/local/crowdsec/lua/haproxy/
11+
- templates:/var/lib/crowdsec-haproxy-spoa-bouncer/html/
12+
- lua:/usr/lib/crowdsec-haproxy-spoa-bouncer/lua/
1313
- geodb:/var/lib/crowdsec/data/
1414
- ./config/crowdsec-spoa-bouncer.yaml.local:/etc/crowdsec/bouncers/crowdsec-spoa-bouncer.yaml.local
1515
networks:
@@ -35,7 +35,7 @@ services:
3535
- ./config/haproxy-upstreamproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
3636
- ./config/crowdsec-upstreamproxy.cfg:/etc/haproxy/crowdsec.cfg
3737
- sockets:/run/
38-
- templates:/var/lib/crowdsec/lua/haproxy/templates/
38+
- templates:/var/lib/crowdsec-haproxy-spoa-bouncer/html/
3939
- lua:/usr/lib/crowdsec-haproxy-spoa-bouncer/lua/
4040
# HAProxy is now only accessible via nginx (not exposed directly)
4141
depends_on:

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
- crowdsec
1010
volumes:
1111
- sockets:/run/
12-
- templates:/var/lib/crowdsec/lua/haproxy/templates/
13-
- lua:/usr/local/crowdsec/lua/haproxy/
12+
- templates:/var/lib/crowdsec-haproxy-spoa-bouncer/html/
13+
- lua:/usr/lib/crowdsec-haproxy-spoa-bouncer/lua/
1414
- geodb:/var/lib/crowdsec/data/
1515
- ./config/crowdsec-spoa-bouncer.yaml.local:/etc/crowdsec/bouncers/crowdsec-spoa-bouncer.yaml.local
1616
networks:
@@ -37,7 +37,7 @@ services:
3737
- ./config/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
3838
- ./config/crowdsec.cfg:/etc/haproxy/crowdsec.cfg
3939
- sockets:/run/
40-
- templates:/var/lib/crowdsec/lua/haproxy/templates/
40+
- templates:/var/lib/crowdsec-haproxy-spoa-bouncer/html/
4141
- lua:/usr/lib/crowdsec-haproxy-spoa-bouncer/lua/
4242
ports:
4343
- "9090:9090"

0 commit comments

Comments
 (0)