N°9519 - Add proxy to Webhook Request - #29
Conversation
|
Hi, I have uploaded the pull request with the proposed changes related to proxy support. PR: #29 Please let me know if you would like me to add more details or make any adjustments. Best regards, |
There was a problem hiding this comment.
Quick remark, please make the code comments in English so everyone can understand them.
Also, be aware that your changes make that these proxy settings are now applied by default for all new users!
And I guess the people from Combodo will require you to fill in the request template, You seem to have removed it all (in your initial post)
|
Hello, thank you for your PR ! We'll review your code in sprint 3.4, that should start at the end of summer (from September). |
|
Really useful contribution — thank you! 🙏 From a field perspective, this is critical in production: when the iTop server has no direct Internet access, webhooks can't go out at all, making the whole integration unusable. Native proxy support would unblock a common deployment scenario. Two small things to tidy up (besides the points already raised by the maintainers):
(Optional: making |
When the iTop server has no direct Internet access, webhook calls cannot go
out at all. This adds an optional proxy for the webhooks outgoing calls,
configured through the module settings:
'proxy' => [
'host' => '10.0.0.1:3128',
'user' => '',
'password' => '',
'no_proxy' => ['localhost', '127.0.0.1', '.internal.example.com'],
],
The proxy CURL options (CURLOPT_PROXY, CURLOPT_PROXYTYPE and, when a user is
given, CURLOPT_PROXYUSERPWD) are injected in WebRequestSender::SendSynchronously,
which is also the code path used by asynchronous sends since the background task
calls Send() with ENUM_SEND_MODE_SYNC.
'no_proxy' makes the proxy selective, following the semantics of curl's no_proxy
environment variable ('*', '.domain.tld' and exact host, case insensitive).
Without it the proxy is forced on every destination, which breaks webhooks
targeting internal hosts: the proxy answers HTTP 503 on the CONNECT because it
cannot reach them. A typical setup has one webhook reaching the Internet through
the corporate proxy and another one targeting an internal automation server that
must be reached directly.
Backward compatible: 'host' defaults to an empty string, so nothing goes through
a proxy unless it is explicitly configured. HostMatchesNoProxy() returns false on
an empty host or a malformed list, i.e. the proxy is applied, preserving the
previous behaviour.
84a095d to
7ce99fb
Compare
|
Updated: the branch is now rebased on top of Two changes since the first version, both worth a look: 1. The shipped default of The previous revision shipped 2. New A global proxy is not enough in practice. A common setup has one webhook reaching the Internet (e.g. Telegram) that needs the corporate proxy, and another one targeting an internal automation server (e.g. n8n) that must be reached directly. Forcing the proxy on the internal one makes it fail with
'proxy' => [
'host' => '10.0.0.1:3128',
'user' => '',
'password' => '',
'no_proxy' => ['localhost', '127.0.0.1', '.internal.example.com'],
],
Note that the injection point ( This has been running in production on our instance, with both cases side by side. |
There was a problem hiding this comment.
Pull request overview
Adds configurable HTTP proxy support for outbound webhook requests.
Changes:
- Injects proxy and optional authentication into cURL options.
- Supports proxy bypass rules through
no_proxy. - Adds default proxy configuration settings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Service/WebRequestSender.php |
Applies proxy configuration and bypass matching. |
module.combodo-webhook-integration.php |
Defines proxy defaults and exclusions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (!empty($aProxyConf['user'])) { | ||
| $sAuth = $aProxyConf['user']; | ||
| if (!empty($aProxyConf['password'])) { | ||
| $sAuth .= ':'.$aProxyConf['password']; | ||
| } |
| * @param mixed $aNoProxy Exclusion list (array of strings) | ||
| * | ||
| * @return bool | ||
| * @since 1.4.10 |
Symptom (bug) / Objective (enhancement)
In many enterprise environments, iTop servers do not have direct access to the Internet and must route all outbound HTTP/HTTPS traffic through a corporate proxy.
Currently, the webhook integration module does not provide any way to configure a proxy for outbound requests.
As a result, webhook calls fail in restricted networks, usually with DNS resolution or connection errors, making integrations with external services (Telegram, Slack, APIs, etc.) unusable.
The objective of this enhancement is to allow webhook HTTP requests to be routed through a configurable proxy, making the webhook integration usable in secured and restricted infrastructures.
Reproduction procedure (bug)
(Not applicable, this is an enhancement and not a bug.)
Cause (bug)
(Not applicable, this is an enhancement and not a bug.)
Proposed solution (bug and enhancement)
The solution adds optional HTTP proxy support to the webhook request sender:
The proxy configuration is read from the module settings:
host(mandatory)user(optional)password(optional)When a proxy is defined, the corresponding CURL options are injected into the request:
CURLOPT_PROXYCURLOPT_PROXYTYPECURLOPT_PROXYUSERPWD(if authentication is configured)When no proxy is defined, the behavior remains unchanged, ensuring full backward compatibility.
This allows webhook integrations to work transparently in environments where Internet access is only available through a proxy.
The change is limited to the webhook integration module and does not impact any other part of iTop.