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
add tls config for http client in proxy middleware #1393
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Thx, could you add a description/example here https://github.com/gofiber/fiber/blob/master/middleware/proxy/README.md and a test |
@ReneWerner87 example updated. but I don't know how to write a test that mock a https server and use a self-signed certificate 😿 |
please check we have already deposited a test certificate which you can use, please have a look at the tests, think you can come up with an idea, you can also do it like with the client agent test |
@ReneWerner87 test added, please have a check. |
Could you check the unittests again, there is an error and maybe its related to the test code changes. |
@ReneWerner87 Does it mean clientTlsConfig should be protected by a mutex? But they're all ok in my local test environment. |
will also analyze it again, give me a little time, don't know if i will make it today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code looks good, i just noticed that you set this tls config global and it is only present once
for the client that does the DO and FORWARD without further settings this is completely ok
but with the other variant of the BALANCER or with the NEW method this is not ok, because this middleware could be used multiple times for different routes, i would also expect that it can behave differently in these, i.e. the tls configuration would have to be injected via the config
sorry for the late comment, can you extend the config and possibly the test, so that it tests both cases, the DO/FORWARD and the Balancer
@ReneWerner87 Thanks! |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
In some cases, we often need to disable certificate validation, so I add
WithTlsConfig
function for proxy.This function can be used before
Forward
, for example: