I am experiencing periodic request failures when accessing my webapp using Traefik.
I am using:
- Dockerized Flask app served with Gunicorn
- official postgres docker container
- official Traefik docker container
- docker-compose to start all the above containers
Everything runs on a single AWS EC2 instance. I am mainly using Traefik to get the automatically generated SSL cert from letsencrypt
For the most part everything works as I would hope. However periodically when loading my page in the browser it hangs. When I check the network tab I can see some of the requested documents have failed to load.
I turned on access logs and set the log level to DEBUG in Traefik and reloaded my page until I was able to see the error. The first time I was able to capture the error the logs did not indicate anything was wrong. They showed Traefik responding with the document with a 200 response. Here is the relevant log portion and a screen shot of the safari network pane
log: https://pastebin.com/DUegF4UU
After capturing more successes and failures I was ultimately able to see an error that might be relevant in the logs:
traefik | time="2019-01-09T22:14:54Z" level=debug msg="Request has been aborted [96.92.159.193:63283 - /admin/static/vendor/jquery.min.js?v=2.1.4]: net/http: abort Handler"
traefik | time="2019-01-09T22:15:08Z" level=debug msg="http: TLS handshake error from 96.92.159.193:37272: EOF"
Here is the full collection of relevant log lines: https://pastebin.com/9uXxFDEs
And the network pane:
Some things to note:
1) This does not happen with every request
2) Even when it does happen, I do not necessarily see an error
3) Out of 10 failures I capured with DEBUG logging the "Request has been aborted" error showed up twice and the "TLS handshake error" showed up once
Just for completeness, here is the log and network pane for a successful request:
log: https://pastebin.com/f1WhUWYk
Here is my traefik.toml file:
debug = false
logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"]
[web]
# Port for the status page
address = ":8080"
[web.auth.basic]
users = ["admin:nope"]
# Entrypoints, http and https
[entryPoints]
# http should be redirected to https
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
# https is the default
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# Enable ACME (Let's Encrypt): automatic SSL
[acme]
# Email address used for registration
email = "mine"
storageFile = "/etc/traefik/acme.json"
entryPoint = "https"
onDemand = false
OnHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[retry]
# Enable Docker configuration backend
[docker]
endpoint = "unix:///var/run/docker.sock"
watch = true
exposedbydefault = false
Please let me know if any more information might be helpful.
EDIT: After more experimentation it seems I only get the response failures when Traefik is running in a docker container. When I run it straight on the host machine (with my app still running in docker) then I no longer see any issues.


