-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect generate wrong access logs #2565
Comments
I haven't looked at the code yet. I'll see if I can pin down the issue. |
@jdel Thanks for your interest on Træfik. To me it is not an issue. Because with your example it is normal to have two lines of log. You send a request on the entrypoint who listen on port 8880, you have configured this entrypoint to redirect to the https entrypoint who listen on 8443. So when Træfik receives the request it responses with a 302 Found and you client will do an other request on the value of the Location headers in the response. $ curl -ILs -H 'Host:nginx1.test.tld' http://127.0.0.1:8880/
HTTP/1.1 302 Found
Location: http://nginx1.test.tld:8443/
Date: Tue, 02 Jan 2018 15:17:53 GMT
Content-Length: 5
Content-Type: text/plain; charset=utf-8
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 612
Content-Type: text/html
Date: Tue, 02 Jan 2018 15:17:53 GMT
Etag: "5a21d078-264"
Last-Modified: Fri, 01 Dec 2017 21:58:16 GMT
Server: nginx/1.12.2 |
Hello @mmatur, Thanks for looking into this. Indeed, due to the weird first line in the log, I assumed the redirection was done internally for some reason and I didn't even check. My bad. It does make sense to have two entries in the log but then the first one should be formed properly, show the status code 302 and the correct frontend name. If you look at my test case above, currently, the first line always shows the same front end name. The following curl commands (without following redirection):
Generate the following access logs
It always shows Host-nginx1-test-tld-3 when it's not alwazs the case. Eventually, some info about the entrypoint would be nice too in order to filter the logs. |
Hello @jdel, I can confirmed that there is an issue with the host name. Nice catch Like explained here it is normal that the 302 status is not present // OriginStatus is the map key used for the HTTP status code returned by the origin server.
// If the request was handled by this Traefik instance (e.g. with a redirect), then this value will be absent. |
Yes that's what I assumed, there is some internal things going on there. Is there any technical reason not to have the original status in the access log ? I might be the only one using the access log feature with a log analyzer to parse the logs, but to me this seems fundamental, as an empty status code will basically be treated as invalid by most log analyzers. |
Thanks for your feedback. I am working on a fix |
Thanks a lot. My Go is not good enough to attempt a fix myself, but I can do tests if it's any help. |
Do you want to request a feature or report a bug?
Reporting a bug
What did you do?
Run traefik with http redirected to https and examine access logs.
What did you expect to see?
A single curl on nginx1 generates 1 line in the access log:
A single curl on nginx2 generates 1 line in the access log:
What did you see instead?
A single curl on nginx1 generates 2 lines in the access log:
Now a curl on nginx2 shows a erroneous output in the first line:
Output of
traefik version
: (What version of Traefik are you using?)What is your environment & configuration (arguments, toml, provider, platform, ...)?
Traefik run with:
Now run 3 nginx:
A single curl on nginx1 generates 2 lines in the access log:
Now a curl on nginx2 shows a weird behaviour:
The first lime says we're hitting
Host-nginx1-test-tld-3
which is not correct.Same goes with nginx3:
The text was updated successfully, but these errors were encountered: