Skip to content

fix(core): Fix HTTP proxy support in all nodes and other axios requests #16092

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 5 commits into from
Jun 10, 2025

Conversation

elsmr
Copy link
Member

@elsmr elsmr commented Jun 6, 2025

Summary

Fix support for HTTP(s) proxies

  • Disable axios built-in proxy because of Proxy support does not work properly with CONNECT on https requests axios/axios#4531
  • When a user configures a proxy in the HTTP Request node, use it
  • Use HTTP_PROXY/HTTPS_PROXY/ALL_PROXY/NO_PROXY env vars
    • using proxy-from-env (same package as axios)
    • Apply to
      • All nodes including HTTP request node (when no proxy configured in node UI)
      • All other axios requests made from the backend using interceptor
      • Also proxies after redirects

Tested with tinyproxy

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-2942/http-request-node-proxy-issue
Fixes: #7037

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)

Copy link
Contributor

@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 5 files and found no issues. Review PR in cubic.dev.

@dana-gill dana-gill self-requested a review June 6, 2025 10:12
@elsmr elsmr requested review from a team and schrothbn June 6, 2025 10:20
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 86.36364% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...xecution-context/utils/request-helper-functions.ts 86.36% 7 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jun 6, 2025
schrothbn
schrothbn previously approved these changes Jun 6, 2025
Copy link
Contributor

@schrothbn schrothbn left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Contributor

github-actions bot commented Jun 6, 2025

✅ All Cypress E2E specs passed

Copy link
Contributor

@dana-gill dana-gill left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-06-06 at 16 22 02

I'm getting this error with the HTTP Node while using GET. POST does work though 😄

pnpm-lock.yaml Outdated
Comment on lines 27104 to 27113
debug: 3.2.7(supports-color@5.5.0)
debug: 3.2.7(supports-color@8.1.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there are dependencies here which shouldn't be updated 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

Anything I can do about this? I just did pnpm add proxy-from-env on node.js v22.16.0, pnpm v10.11.1.

In any case, don't think supports-color would cause trouble 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Beyond going through the file manually, honestly not really 😞 I'm just not a big fan of updating dependencies that aren't meant to be updated

@elsmr
Copy link
Member Author

elsmr commented Jun 9, 2025

I'm getting this error with the HTTP Node while using GET. POST does work though 😄

Did you do a full rebuild? I tried this exact request and it works:

image

@elsmr elsmr requested a review from dana-gill June 9, 2025 08:19
@pemontto
Copy link
Contributor

pemontto commented Jun 9, 2025

This PR proxies HTTPS great using the CONNECT protocol 🎉
However it seems HTTP (non-SSL) connection no longer respect the proxy and try to go directly, even when specific in the node settings.

Running squid: docker run --name squid -e TZ=UTC -p 3128:3128 ubuntu/squid
Running n8n: N8N_DEV_RELOAD=true N8N_USER_MANAGEMENT_DISABLED=true HTTP_PROXY=http://localhost:3128 HTTPS_PROXY=http://localhost:3128 pnpm start
Wireshark filter: tcp.port == 3128
tcpdump: tcpdump -i lo0 port 3128

Expand workflow JSON
{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        -120
      ],
      "id": "5a1498dc-394a-4864-838f-ce800f13f8cc",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "url": "http://httpbingo.org/anything/HTTP",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        -380
      ],
      "id": "3df71009-bccb-4ecb-aeaf-7e5b821cfd04",
      "name": "HTTP"
    },
    {
      "parameters": {
        "url": "https://httpbingo.org/anything/HTTPS",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        -220
      ],
      "id": "6b3984c0-fb5b-4b83-82a9-5eee0551e609",
      "name": "HTTPS"
    },
    {
      "parameters": {
        "url": "http://httpbingo.org/anything/HTTP-with-proxy",
        "options": {
          "proxy": "http://localhost:3128"
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        -60
      ],
      "id": "fdb3837c-6dd1-44fe-9221-567b2cf83037",
      "name": "HTTP Proxy"
    },
    {
      "parameters": {
        "url": "https://httpbingo.org/anything/HTTPS-with-proxy",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          },
          "proxy": "http://localhost:3128"
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        100
      ],
      "id": "6a58ed73-da71-455d-bc92-9f74802610b1",
      "name": "HTTPS Proxy"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://httpbingo.org/anything/HTTP",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        -380
      ],
      "id": "3e7f9b23-ce0d-48ff-9c90-4b2c96f1748a",
      "name": "HTTP1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbingo.org/anything/HTTPS",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        -220
      ],
      "id": "4e066d49-83f9-414f-9bd6-1176964ef550",
      "name": "HTTPS1"
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "http://httpbingo.org/anything/HTTP-with-proxy",
        "options": {
          "proxy": "http://localhost:3128"
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        -60
      ],
      "id": "d1062d75-4d92-4bce-ba48-7c7bdc39342f",
      "name": "HTTP Proxy1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbingo.org/anything/HTTPS-with-proxy",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          },
          "proxy": "http://localhost:3128"
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        100
      ],
      "id": "efe9f0f2-bdd1-4929-913a-5644e5e34263",
      "name": "HTTPS Proxy1"
    }
  ],
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "HTTP",
            "type": "main",
            "index": 0
          },
          {
            "node": "HTTPS",
            "type": "main",
            "index": 0
          },
          {
            "node": "HTTP Proxy",
            "type": "main",
            "index": 0
          },
          {
            "node": "HTTPS Proxy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP": {
      "main": [
        [
          {
            "node": "HTTP1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTPS": {
      "main": [
        [
          {
            "node": "HTTPS1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Proxy": {
      "main": [
        [
          {
            "node": "HTTP Proxy1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTPS Proxy": {
      "main": [
        [
          {
            "node": "HTTPS Proxy1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

@elsmr
Copy link
Member Author

elsmr commented Jun 9, 2025

This PR proxies HTTPS great using the CONNECT protocol 🎉 However it seems HTTP (non-SSL) connection no longer respect the proxy and try to go directly, even when specific in the node settings.

Hey @pemontto thanks for testing! Plain HTTP proxying should be fixed in my last commit 🎉

@pemontto
Copy link
Contributor

pemontto commented Jun 9, 2025

@elsmr working nicely now!

1749495492.052    106 172.17.0.1 TCP_MISS/200 979 GET http://httpbingo.org/anything/HTTP - HIER_DIRECT/66.241.125.232 application/json
1749495492.166    104 172.17.0.1 TCP_MISS/200 996 POST http://httpbingo.org/anything/HTTP - HIER_DIRECT/66.241.125.232 application/json
1749495492.305    125 172.17.0.1 TCP_TUNNEL/200 3451 CONNECT httpbingo.org:443 - HIER_DIRECT/66.241.125.232 -
1749495492.437    121 172.17.0.1 TCP_TUNNEL/200 3455 CONNECT httpbingo.org:443 - HIER_DIRECT/66.241.125.232 -
1749495492.551     96 172.17.0.1 TCP_MISS/200 987 GET http://httpbingo.org/anything/HTTP-with-proxy - HIER_DIRECT/66.241.125.232 application/json
1749495492.684    116 172.17.0.1 TCP_MISS/200 1005 PATCH http://httpbingo.org/anything/HTTP-with-proxy - HIER_DIRECT/66.241.125.232 application/json
1749495492.812    117 172.17.0.1 TCP_TUNNEL/200 3458 CONNECT httpbingo.org:443 - HIER_DIRECT/66.241.125.232 -
1749495492.943    117 172.17.0.1 TCP_TUNNEL/200 2970 CONNECT httpbingo.org:443 - HIER_DIRECT/66.241.125.232 -

Copy link
Contributor

@dana-gill dana-gill left a comment

Choose a reason for hiding this comment

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

I'm currently having issues on my instance testing this for https but since this is working for @elsmr and for other users, I'm approving.

Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link
Contributor

✅ All Cypress E2E specs passed

@elsmr elsmr merged commit e3675bd into master Jun 10, 2025
33 checks passed
@elsmr elsmr deleted the node-2942-http-request-node-proxy-issue branch June 10, 2025 12:42
This was referenced Jun 11, 2025
@github-actions github-actions bot mentioned this pull request Jun 11, 2025
@janober
Copy link
Member

janober commented Jun 11, 2025

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

axios and https proxy - is it possible to revert request lib drop?
5 participants