[Bug] SafeLine reports almost all requests as 502 when using Traefik plugin
SafeLine version
9.4.3
Bug description
What happened:
SafeLine reports almost all requests as 5xx errors originating from SafeLine when using the official Traefik plugin, even though the protected application is accessible and normal requests return HTTP 200.
The statistics dashboard showed:
- 694 total requests
- 688 5xx errors
- 99.14% error rate
The 5xx tooltip showed Error from SafeLine: 688 and Error from upstream server: 0.
The safeline-luigi log contained an aggregated statistics entry with status 502 and an empty site_id:
INSERT INTO "statistics_basics"
("time","type","key","content_type","method","path","site_id","count")
VALUES (1794245166,'waf_status_code','502','','','','',144)
Two different SQL injection tests produced different results:
-
A test using the query parameter
test=1' OR '1'='1was not blocked:curlreceived HTTP 200. SafeLine recorded this exact request in Attacks → Logs asTimeout, withAudited / AllowandNo Responsein the response details. One attempt took approximately 2.47 seconds; a later attempt returned HTTP 200 in approximately 0.046 seconds. -
A test using
?1=1%20and%202=2was blocked:curlreceived HTTP 403 with the SafeLine block message. The event appeared in Attacks → Logs asBlocked / SQL Inj.
The semantic analysis configuration shows Balance Mode selected for SQL injection.
What did I expect:
- Successful HTTP 200 responses should not be counted as SafeLine 502 errors.
- The
Timeout / Allow / No Responseevent for the first test should be explained, including why the request was allowed. - I would like to know whether the different results for the two test requests are expected.
Environment:
- SafeLine CE 9.4.3
- Traefik v3.7
traefik-safelineplugin v1.4.0- Ubuntu 24.04 LTS
- Docker Compose
- Protected application: self-hosted NetBird dashboard
Traffic path:
Client → Traefik → SafeLine detector via plugin → NetBird dashboard
Traefik and safeline-detector share a Docker network. The detector listens on TCP port 8000. No applications are configured in the SafeLine Applications page.
Traefik middleware:
http:
middlewares:
safeline-check:
plugin:
safeline:
addr: "safeline-detector:8000"
Additional diagnostics:
safeline-detectoris currently running and reportshealthy.- Recent Traefik and detector Docker logs showed no error corresponding to the test request.
- During an earlier startup, detector logs showed connection refusals to
127.0.0.1:18001, and FVM loggedPush FSL response(502). Later FVM logs reportedPush FSL success. It is unclear whether those earlier errors are related. - A potentially related plugin issue is https://github.com/chaitin/traefik-safeline/issues/8, but I did not observe its
broken pipemessage.
Questions for the maintainers:
- Why are successful requests counted as SafeLine 502 errors?
- Does the Traefik plugin report upstream response statuses to SafeLine? Could this affect the statistics?
- What does
Timeout / Allow / No Responsemean in this setup, and which logs or debug settings should be enabled to find the cause? - Is an entry in SafeLine Applications required when using the Traefik plugin?
- Is the different behavior between the two SQL injection tests expected, or does the first event indicate a detection problem?
- Is there a recommended configuration or fix for reliable detection and statistics with this integration?
Steps to reproduce (if available)
- Deploy SafeLine and Traefik using Docker Compose.
- Configure the
traefik-safelineplugin to connect tosafeline-detector:8000. - Attach the middleware to the Traefik router for a web application.
- Open and browse the application, then check Statistics → Traffic Analysis for 5xx errors.
- Send these two test requests, replacing
example.comwith the protected domain:
curl -iG --data-urlencode "test=1' OR '1'='1" https://example.com/
curl -i 'https://example.com/?1=1%20and%202=2'
- Compare the HTTP responses with the events in Attacks → Logs.
In my deployment, the first test returned HTTP 200 and was logged as Timeout / Audited / Allow / No Response; the second returned HTTP 403 and was logged as Blocked / SQL Inj.
Logs or screenshots (optional)
No response
I found a similar report in the Traefik plugin repository: https://github.com/chaitin/traefik-safeline/issues/6
That user also reports that blocking works while the SafeLine dashboard continuously shows gateway timeouts. Is this the same issue as the 502 statistics and Timeout / Allow events in my deployment? Is there a recommended fix or configuration?
Hi @dejikoru-hub, thanks for putting together such a thorough report — really appreciate it.
To address your questions:
-
The difference between the two test requests is expected. SQL injection detection runs in Balanced mode by default, which catches
1=1 and 2=2right away.1' OR '1'='1is a subtler variant, and it gets detected once you switch the Semantic Analysis SQL injection protection to Strict Mode. -
Unfortunately, we don't have integration documentation for the Traefik plugin at the moment — sorry about that.
-
As for the 502 statistics, we'd like to dig into it a bit further. Could you share the error logs from both your site and the upstream? Once we've had a look, we'll follow up with you.
Hi @Windsley ! Thanks for your response.
I have switched the SQL injection protection to Strict mode. I will test it again and share the results.
Regarding the 502 statistics, could you clarify which specific logs you need? My setup uses Traefik with the SafeLine plugin, and the affected requests are routed to several services. Do you need Traefik logs, SafeLine detector logs, or logs from the backend applications? Please also let me know what time range and log level would be useful.
I will collect the relevant logs and remove any sensitive information before sharing them.
Hi @dejikoru-hub !Please provide the logs listed below for the 5–10 minutes before and after the 502 anomaly, covering the same time window, with timestamps and time zones noted:
- Traefik access logs: JSON format preferred, retain normal 200 responses, including request time, domain, path,
DownstreamStatusand OriginStatus. - Traefik runtime logs: including error outputs from the SafeLine plugin.
- Logs from the
safeline-detectorandsafeline-luigicontainers. - Access logs and error logs of the corresponding backend service: start with one reproducible service only.
Also provide a URL for the reproduction request, the actual HTTP response code, and screenshots of the breakdown items for "Error returned by SafeLine / Error returned by upstream" shown in the SafeLine 5xx prompt.