Fix: Connectivity check fails with Squid/Strict Proxies (Force CONNECT on port 80)#2524
Fix: Connectivity check fails with Squid/Strict Proxies (Force CONNECT on port 80)#2524limetech merged 1 commit intounraid:masterfrom
Conversation
fix proxy_online
WalkthroughThe change modifies the OutgoingProxyLib.php to use a dynamic check URL for NC SI status instead of a hardcoded value, and conditionally enables HTTP proxy tunneling based on whether the check URL uses HTTPS. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@emhttp/plugins/dynamix/include/OutgoingProxyLib.php`:
- Around line 61-71: The current $checkurl is hardcoded to
"http://www.msftncsi.com/ncsi.txt" which makes the $isHttps check and
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $isHttps) dead code; update the code
to either (A) make $checkurl configurable (e.g., accept it from a function
parameter or configuration value) so parse_url($checkurl, PHP_URL_SCHEME) can be
'http' or 'https' at runtime and the existing $isHttps logic works, or (B) if
only HTTP will ever be used, remove the conditional and explicitly set
CURLOPT_HTTPPROXYTUNNEL to false to reflect the intended behavior; adjust
references to $checkurl and $isHttps accordingly.
|
The purpose of the test is to confirm whether the server can read http://www.msftncsi.com/ncsi.txt over the proxy. If the proxy you want to use does not support http then the proxy needs to be improved, it does not make sense to disable the http check for everyone else. Or what am I missing? |
|
I think there is a misunderstanding on the technical cause of the failure. I am not trying to disable the HTTP check, but to fix how the request is made when a proxy is configured. Currently, the code forces CURLOPT_HTTPPROXYTUNNEL = true. When the URL is HTTP (like the NCSI test), cURL sends a CONNECT request to the proxy on port 80. If the URL is http://, we use a standard GET request (Tunneling OFF). This fix actually enables the check to work for everyone using a standard proxy, which is currently broken and leads to a false 'Offline' status. |
|
Thanks, I think you are right. I'll do some testing and will most likely recommend that this be merged. |
The Issue
The current implementation forces
CURLOPT_HTTPPROXYTUNNELtotruefor all connectivity checks.The check URL is currently
http://www.msftncsi.com/ncsi.txt(Plain HTTP).When
CURLOPT_HTTPPROXYTUNNELis enabled on an HTTP URL, cURL sends aCONNECTmethod request on port 80 (instead of a standardGET).Most strict proxy configurations (like Squid's default
safe_ports) explicitly block theCONNECTmethod on non-SSL ports to prevent protocol tunneling security risks.This causes Unraid to incorrectly report "Offline" status even when connectivity is fine.
The Fix
This PR refactors
proxy_onlineto make the tunneling option conditional:$checkurl.https://-> Enable Tunneling (True).http://-> Disable Tunneling (False).This ensures compatibility with standard proxy configurations while remaining robust if the check URL is changed to HTTPS in the future.
References / Community Reports
https://forums.unraid.net/topic/190733-712-outgoing-proxy-how/
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.