1. The problem I’m having:
I am new in Go and Caddy plugin, recentlly I developed a WAF plugin referred to the docs example, its principle like the picture.
- User’s request reach caddy and be forwarded to the WAF engine by WAF plugin.
- WAF response the action about this request, pass or blocked.
- If pass, the user’s request will be forwarded to the upstreams. If blocked, the caddy WAF plugin return the error page to the user.
I have deployed it to my stage environment, but I found it has some new problems compared to the vanilla caddy:
- Sometimes it will block the requests(not security reason) until restart the caddy or deactivate the WAF plugin.
- Sometimes it takes up a huge amount of memory even OOM.
- Sometimes it takes up more memory than usual.
- After I reload the caddy, I noticed that there are double current Established TCP to the WAF engine, seems run 2 instances of WAF plugin?
How can I debug the memory problem? I have tried the method in docs, but I can’t find the reason.
Additional, does caddy exec some function(like conn.Close()) after reload the caddy? How can I debug the reload progress?
2. Error messages and/or full log output:
Nothing
3. Caddy version:
v2.8.4
4. How I installed and ran Caddy:
a. System environment:
Debian 12 amd64, run with systemd
b. Command:
xcaddy run
d. My complete Caddy config:
(waf) {
route {
waf_chaitin {
waf_engine_addr 192.168.1.101:8000
pool_size 10
}
}
https://*.buct.edu.cn {
encode zstd gzip
import waf
reverse_proxy * {
to http://192.168.1.200
}
@site1 host site1.buct.edu.cn
handle @site1 {
encode zstd gzip
import waf
reverse_proxy * http://192.168.1.201
}
@site2 host site2.buct.edu.cn
handle @check {
encode zstd gzip
import waf
reverse_proxy * http://192.168.1.202
}