Skip to content

fix(core): Add support for proxy using forward headers #15006

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

Merged
merged 7 commits into from
May 22, 2025

Conversation

Phiph
Copy link
Contributor

@Phiph Phiph commented Apr 30, 2025

Summary

This pull request introduces support for proxies in the Push class by utilizing X-Forwarded headers to determine the expected origin, along with enhanced logging to debug origin-related issues.

Support for proxies:

  • Added logic to prefer X-Forwarded-Host and X-Forwarded-Proto headers over the standard Host and Origin headers to compute the expectedOrigin. This ensures compatibility when the application is behind a proxy.

Enhanced logging:

  • Introduced detailed debug logs to capture the values of Host, Origin, X-Forwarded-Host, X-Forwarded-Proto, and the computed expectedOrigin. This helps in identifying mismatches between the Origin header and the expectedOrigin.

Related Linear tickets, Github issues, and Community forum posts

fixes: #14619, #14653

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CLAassistant
Copy link

CLAassistant commented Apr 30, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 3 issues across 1 file. View them in mrge.io

@n8n-assistant n8n-assistant bot added community Authored by a community member core Enhancement outside /nodes-base and /editor-ui in linear Issue or PR has been created in Linear for internal review labels Apr 30, 2025
@Joffcom
Copy link
Member

Joffcom commented Apr 30, 2025

Hey @Phiph,

Thanks for the PR, We have created "GHC-1804" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

@despairblue despairblue marked this pull request as draft May 20, 2025 16:21
@despairblue despairblue marked this pull request as ready for review May 20, 2025 16:21
@Phiph
Copy link
Contributor Author

Phiph commented May 20, 2025

hey @despairblue thanks for adding the tests and cleaning up the implementation. :) I was going to look at the tests tomorrow! I appreciate it!

Is there anything you'd like me to do?

@despairblue despairblue changed the title fix: add support for proxy backends fix(core): Add support for proxy using forward headers May 20, 2025
@despairblue
Copy link
Contributor

hey @despairblue thanks for adding the tests and cleaning up the implementation. :) I was going to look at the tests tomorrow! I appreciate it!

Is there anything you'd like me to do?

No problem. Thanks for the initial work ❤️

@despairblue despairblue requested a review from Cadiac May 20, 2025 16:24
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic reviewed 2 files and found no issues. Review PR in cubic.dev.

Copy link
Contributor

@Cadiac Cadiac left a comment

Choose a reason for hiding this comment

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

Left some comments, but overall this looks like a good solution to solve the issue we have 👍

* precedence over `host`.
* If they are not both defined then `host` is used and the protocol is
* inferred from `origin`.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

There's also Forwarded header with an optional host field that some people might use, but we can discuss adding support for that on another ticket too.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Forwarded

Copy link
Contributor

@Cadiac Cadiac left a comment

Choose a reason for hiding this comment

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

🚀

@shortstacked
Copy link
Contributor

/test-workflows

@despairblue despairblue merged commit b1687c6 into n8n-io:master May 22, 2025
15 of 17 checks passed
@Phiph Phiph deleted the proxy-backends branch May 23, 2025 11:54
ozcangungor pushed a commit to ozcangungor/n8n that referenced this pull request May 25, 2025
etobella pushed a commit to etobella/n8n that referenced this pull request May 25, 2025
@github-actions github-actions bot mentioned this pull request May 26, 2025
@janober
Copy link
Member

janober commented May 26, 2025

Got released with [email protected]

@neylwalecki
Copy link

Tested with my setup on AWS + Ubuntu + Litespeed Web Server + CyperPanel, and unfortunately it doesn't fix the "lost connection/websocket" issue. It seems that the culprit is the Litespeed Web Server.

Alexandero89 pushed a commit to Alexandero89/n8n that referenced this pull request May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member core Enhancement outside /nodes-base and /editor-ui in linear Issue or PR has been created in Linear for internal review Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocket "Connection lost, code=1008" with Cloudflare Tunnel in n8n 1.88.0 and 1.89.0
8 participants