crowdsec-bouncer-traefik-plugin: [BUG] Traefik v3 does not render correctly html ban page
Describe the bug ๐ When using the provided ban.html and providing it with the option, it gets printed even through the html renders if you test it in a html renderer.
Expected behavior ๐ The html getting rendered.
Context ๐
Configuration:
- "traefik.http.middlewares.crowdsec.plugin.bouncer.enabled=true"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdseclapikey=APIKEY"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.logLevel=DEBUG"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.banHTMLFilePath=/ban.html"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdsecLapiHost=crowdsec:8080"
No error in logs were found.
Version (please complete the following information):
- OS: Docker
- Traefik version: 3.0.0
- Plugin version: 1.3.0
- Redis: ?
To Reproduce Steps to reproduce the behavior:
- Put configuration.
- Activate middleware.
- Ban yourself.
- Try to go to the service.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (3 by maintainers)
Hey all, I just find that the security headers that is problematic here is
contentTypeNosniff: trueIf you remove it, the ban page is displayed as usual. Then the set Content-Type here does not work as expected:You were right, I was blind to my own mistake ๐ฅฒ. Thanks a lot all, I will make a PR to fix it. See you next release ๐
Hey, the xKhronozโs solution worked, thank you so much!
I can also confirm I had multiple middlewares. If further configuration is needed please tell me and I will try to help.
I might have found the root cause of my issue, at least with regards to the way I setup Traefik, Crowdsec, and my other service, as I separate my services into their own docker-compose files depending on their use case, with the use of the โDynamicโ Configuration File to setup a few common Middlewares that are shared across my services and the use of โChainโ Middleware to combine these middleware into one, including this plugin.
Saw that @benscobie mentioned that it could be related to the new Traefik V3 update not supporting content type auto detection by default and decided to investigate a bit. After some tinkering around adding in the auto content type detection middleware finally got the html page to be rendered correctly for me โ at least. Although I am not 100% sure if the problem happens due to there being more than 1 middleware in used for a service and somehow the content type set by the plugin is not being forwarded or something?
A few variables to tested, (will update with more if I have time) EDITED:
@maxlerebourg and yes I had tried to move the plugin to the last in my middleware chain but it did not work before, however after adding the auto content type detection middleware and moving the plugin middleware to the last in the chain as well did the trick.
TLDR Solution (if you are using multiple Middleware / Middleware Chain):
Setup and add the auto detection of content type middleware and move this plugin to the last in the list/chain.
More info to setting that middleware can be found here: https://doc.traefik.io/traefik/middlewares/http/contenttype/
Middleware Chain Ordering
My Dynamic config.yaml
Dynamic config.yaml
Let me know if you need more information, I will post my other configs.
Would be great if others can confirm whether my solution works for them as well as report how their setup/config are! ๐
I suspect that this might be the change in v3 that causes this: https://doc.traefik.io/traefik/master/migration/v2-to-v3/#content-type-auto-detection
I just ran into the same thing upgrading.
Release v1.3.1 is here, with a fix