Closed cyril-s closed 4 years ago
This looks like an excellent approach. I'll need a little time to review to PR though.
What happen in the case of a 401 (or other non-200/500)?
Generally happy, but I'd like to keep reporting of non-200 responses if possible. Debugging things like 401s, and/or https issues needs to be as easy as possible. I've not had time to read the code, so I apologise if this is dealt with and I'm missing it. Thanks especially for the benchmark tests.
@tcolgate only errors originating from exporter_exporter itself are logged. They are:
Verify: true
All other errors are passed as is from proxied server to the client. But I agree that logging would be useful. I made another PR with access logging. Take a look at #40
okay, we can review logging in the other PR.
Current implementation handles modules with
verify=true
andverify=false
very differently. For the former, it usespromhttp.HandlerFor
helper withhttp.Client
and acts as some kind of gateway while for the latter, it useshttputil.ReverseProxy
and acts as usual http proxy. Some problems are:1) Inconsistent http headers handling.
http.Client
makes request anew whilehttputil.ReverseProxy
copies end-to-end headers 2) Inconsistent error handling.promhttp.HandlerFor
always returns500 Internal Server Error
when302
and304
codes are appropriate, whilepromhttp.HandlerFor
of current implementation returns302
always.I suggest get rid of
promhttp.HandlerFor
and move verification logic intoModifyResponse
hook ofhttputil.ReverseProxy
. This allows for usual http proxy headers handling and better error handling.Error handling changes table:
In summary, this PR changes:
Closes #37