Handle dial failures for allowed IPs by returning Bad Gateway response#194
Open
steffenbusch wants to merge 1 commit into
Open
Handle dial failures for allowed IPs by returning Bad Gateway response#194steffenbusch wants to merge 1 commit into
steffenbusch wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. What does this change do, exactly?
This change fixes the HTTP status returned when a host resolves to at least one IP address allowed by the ACL, but dialing all allowed IPs fails.
Previously, the forward proxy returned
403 Forbiddenin this situation, even though the host itself was permitted by the ACL and the actual failure occurred during connection establishment.The issue can be reproduced even with a configuration that explicitly allows all IPs:
{ debug admin off } :3128 { log forward_proxy { acl { allow all } } }Example:
This also resulted in misleading debug log output such as:
even though allowed IPs were present and connection attempts had actually been made.
With this change:
403 Forbiddenis returned only when no resolved IP addresses are allowed by the ACL502 Bad Gatewayis returned when at least one allowed IP was attempted but all connection attempts failedA regression test was added to verify the corrected behaviour.
2. Please link to the relevant issues.
N/A
3. Which documentation changes (if any) need to be made because of this PR?
None.
4. Checklist
5. AI disclosure
I discovered and narrowed down this issue in my production environment. After analysing the source code, I suspected that the problem originated exactly in the area modified by this change.
I then used ChatGPT to review and validate that assumption. After confirming the likely cause, I implemented the fix myself. GitHub Copilot was subsequently used for minor code refinement, and the regression test case was initially generated with Copilot assistance.