Https_proxy not working

Describe the problem/error/question

@Jon Hi, this is a follow-up of Telegram ERROR: Bad request - please check your parameters - #9 by Jon.

I’ve setup an https proxy, and curl works fine with it.

Ths problem is https_proxy not working for me. It still returen errors.

What is the error message (if any)?

In frontend:

Bad Request

Backend log:

error    | NodeApiError: Request failed with status code 400 "{ file: 'ErrorReporterProxy.js', function: 'report' }"
error    | Error: Request failed with status code 400 "{ file: 'ErrorReporterProxy.js', function: 'report' }"
error    | NodeApiError: Request failed with status code 400 "{ file: 'ErrorReporterProxy.js', function: 'report' }"
error    | Error: Request failed with status code 400 "{ file: 'ErrorReporterProxy.js', function: 'report' }"

Hey @browse,

Does the proxy log show any errors? Is your proxy also configured to use a self signed certificate for the connection or is it a proper cert? Looking at the previous post this is something that I know works so I suspect there is going to be another configuration issue somewhere.

If you are using a self signed certificate that will likely be the issue as the Node instance for n8n won’t trust the certificate and it would fail.

@Jon The proxy log shows it has been routed and no error. I does use self-signed certificate, but I’ve add the CA to the n8n docker image, and add NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt env.

Is there any method to make n8n show more detailed error?
Or, how can I patch n8n’s axios to fix the proxy bug?

Hey @browse,

If the request is being routed then it would suggest that it is a legitimate 400 error and the data you are sending to Telegram is incorrect somewhere. You could try making the same request using the HTTP request node to see what that returns with the full response option on.

@Jon This is what I got from GET https://google.com:

{"status":"rejected","reason":{"message":"503 - \"\"","name":"Error","stack":"Error: 503 - \"\"\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at RedirectableRequest.handleResponse (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:238:9)\n    at RedirectableRequest.emit (node:events:525:35)\n    at RedirectableRequest.emit (node:domain:489:12)\n    at RedirectableRequest._processResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:356:10)\n    at ClientRequest.RedirectableRequest._onNativeResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:62:10)\n    at Object.onceWrapper (node:events:628:26)\n    at ClientRequest.emit (node:events:513:28)\n    at ClientRequest.emit (node:domain:489:12)"}}

Here is the stack:

NodeApiError: Service unavailable - try again later or consider setting this node to retry automatically (in the node settings)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1253:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:652:28)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:596:53

Hey @browse,

That looks like an HTTP 503 error, I would expect Google to work as it works for me. What does your proxy log show for that connection?

@Jon I use V2Ray as proxy. The log just show the traffic has been accepted and been routed and no more detailed. And curl works find with that proxy.

Hey @browse,

Can you try calling https://webhook.site/886c674d-2801-445d-8d3d-cb77b5dae389 to see if that works?

@Jon With the same proxy, curl works fine, n8n didn’t work.

Hey @browse,

What did n8n report back as the error? Looking at the page I can see the curl user-agent but I can’t see one for n8n which makes me wonder if maybe the connection is not going through and there is still some odd proxy setting that Axios is not able to work with.

I can confirm that n8n is still working as expected when using Squid as a proxy.

@Jon When I request webhook.site, the error is:

{"status":"rejected","reason":{"message":"503 - \"\"","name":"Error","stack":"Error: 503 - \"\"\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at RedirectableRequest.handleResponse (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:238:9)\n    at RedirectableRequest.emit (node:events:525:35)\n    at RedirectableRequest.emit (node:domain:489:12)\n    at RedirectableRequest._processResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:356:10)\n    at ClientRequest.RedirectableRequest._onNativeResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:62:10)\n    at Object.onceWrapper (node:events:628:26)\n    at ClientRequest.emit (node:events:513:28)\n    at ClientRequest.emit (node:domain:489:12)"}}

And I also tried in https://app.interactsh.com, the error is different:

{"status":"rejected","reason":{"message":"400 - \"Client sent an HTTP request to an HTTPS server.\\n\"","name":"Error","stack":"Error: 400 - \"Client sent an HTTP request to an HTTPS server.\\n\"\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at RedirectableRequest.handleResponse (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:238:9)\n    at RedirectableRequest.emit (node:events:525:35)\n    at RedirectableRequest.emit (node:domain:489:12)\n    at RedirectableRequest._processResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:356:10)\n    at ClientRequest.RedirectableRequest._onNativeResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:62:10)\n    at Object.onceWrapper (node:events:628:26)\n    at ClientRequest.emit (node:events:513:28)\n    at ClientRequest.emit (node:domain:489:12)"}}

It looks like the server didn’t receive request. It’s so interesting that curl works well and n8n just don’t work. No idea how to debug it.

Hey @browse,

I suspect it could be more oddness with Axios and the way your proxy is configured, Although that second error seems to think an http request was sent almost like the https_proxy isn’t using https. Does your proxy log the url it is getting?

I don’t know V2Ray but I suspect there is going to be some checkbox somewhere that is doing something odd.

@Jon It looks like that my proxy only accept connect method, which doesn’t work with axios.

I’ve looked into squid these days, and I’m a little confused about it’s configuration.
Could you please provide me a working config?
Thanks very much.

Hey @browse,

I can provide you with the steps that I use for testing but it should be considered as just a test environment and for something that you plan to use in production it would be worth investigating a safer configuration.

This assumes you have your SSL certificate under ~/squidcert.pem, If you plan to use a self signed certificate there is more risk involved.

squid.conf
http_port 3128
https_port 3129 cert=/etc/squid/proxy.pem

dns_v4_first on

acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl CONNECT method CONNECT

http_access allow localnet
http_access allow localhost
Docker Compose
version: '3.8'
services:
  squid:
    image: sysdignathan/secure-squid:latest
    ports:
      - "3128:3128"
      - "3129:3129"
    volumes:
      - ~/squid.conf:/etc/squid/squid.conf
      - ~/squidcert.pem:/etc/squid/proxy.pem
      - ~/squidlogs:/var/log/squid
n8n Env
http_proxy=http://squid:3128
http_proxy=https://squid:3129