Skip to content

N°9519 - Add proxy to Webhook Request - #29

Open
ozan-cristan wants to merge 1 commit into
Combodo:masterfrom
ozan-cristan:fix/proxy
Open

N°9519 - Add proxy to Webhook Request#29
ozan-cristan wants to merge 1 commit into
Combodo:masterfrom
ozan-cristan:fix/proxy

Conversation

@ozan-cristan

@ozan-cristan ozan-cristan commented Mar 12, 2026

Copy link
Copy Markdown
Question Answer
Related to a SourceForge thread / Another PR / Combodo ticket? https://sourceforge.net/p/itop/discussion/922361/thread/0b15547ab3/
Type of change? Enhancement

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_PROXY

    • CURLOPT_PROXYTYPE

    • CURLOPT_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.

@ozan-cristan

Copy link
Copy Markdown
Author

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,
Cristian

@Hipska Hipska left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@jf-cbd jf-cbd moved this from First review needed to Pending technical review in Combodo PRs dashboard Mar 13, 2026
@jf-cbd jf-cbd moved this from Pending technical review to Pending review in Combodo PRs dashboard Apr 13, 2026
@jf-cbd

jf-cbd commented Apr 17, 2026

Copy link
Copy Markdown
Member

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).

@jf-cbd jf-cbd moved this from Pending review to Assigned to a sprint in Combodo PRs dashboard Apr 17, 2026
@jf-cbd jf-cbd changed the title Add proxy to Webhook Request N°9519 - Add proxy to Webhook Request Apr 17, 2026
@eviltik

eviltik commented Jun 18, 2026

Copy link
Copy Markdown

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):

  1. Hardcoded placeholder 'ip.roxy:3128' in the default settings — an empty string would keep the feature inert until it's explicitly configured.
  2. Minor: the module version is lowered (1.4.51.4.4) — a rebase on current master (now 1.4.6) will sort this out anyway, just flagging it.

(Optional: making CURLOPT_PROXYTYPE configurable would also cover SOCKS, but HTTP-only is fine for a first pass.)

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.
Copilot AI balanced review requested due to automatic review settings September 1, 2026 16:07
@ozan-cristan

Copy link
Copy Markdown
Author

Updated: the branch is now rebased on top of master (1.4.9), so the conflict in module.combodo-webhook-integration.php is gone — it came from the array()[] reformatting and the version bump. Everything is squashed into a single commit.

Two changes since the first version, both worth a look:

1. The shipped default of host is now an empty string.

The previous revision shipped 'host' => 'ip.roxy:3128' as a default inside 'settings'. Since Config::UpdateIncludes() writes the module's 'settings' into every installation's config-itop.php, and the injection only checks !empty($aProxyConf['host']), merging it as it was would have routed every webhook of every installation through a non-existent proxy. With '' the default behaviour is unchanged: no proxy unless explicitly configured.

2. New no_proxy entry, so the proxy can be applied selectively.

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 Received HTTP code 503 from proxy after CONNECT, because the proxy cannot reach internal destinations.

no_proxy follows the semantics of curl's environment variable — '*', '.domain.tld' (domain and subdomains) and exact host, case insensitive:

'proxy' => [
    'host'     => '10.0.0.1:3128',
    'user'     => '',
    'password' => '',
    'no_proxy' => ['localhost', '127.0.0.1', '.internal.example.com'],
],

HostMatchesNoProxy() returns false on an empty host or a malformed list, i.e. the proxy is applied, preserving the previous behaviour.

Note that the injection point (WebRequestSender::SendSynchronously) also covers asynchronous sends, since the background task calls Send() with ENUM_SEND_MODE_SYNC.

This has been running in production on our instance, with both cases side by side.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +156 to +160
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Assigned to a sprint

Development

Successfully merging this pull request may close these issues.

7 participants