Http request Node not working in NodeRED behind Reverse Proxy

Hello,

i have multible instances of NodeRED in a docker environment. To access them i exposed different Ports for every instance via settings.js and set up a nginx reverse proxy via docker and used virtualports.

So now i can access all NodeRED-instances via different sub-domains with ssl-letsencrypt and regulary with http/443. The reverse proxy passes the sub-domains to different ports: 1881, 1882, 1883...

Everything is fine except one thing:
If i use a http request node to GET any resources from outside in the world i just geht:

RequestError: Bad response: 400

When i use the exec-node with curl it works.

What else is to be done to get the http-request-nodes to work?

Thanks
Bond

Not sure what is happening but you sometimes get issues with and without trailing slashes that can result in failed requests. Might be worth checking. Is it NGINX that is returning the 400 or is it Node-RED responding to the proxy?

You might need to turn up the logging level in NGINX - it logs 400 errors at "info" level, that may give you more information.

400 errors can happen for all sorts of issues though errors in headers are common so you might also want to check whether you are setting any invalid headers in your http-out.

Thanks for your answer,

ok lets get more detailed. Thats the test-flow i use:

[{"id":"a19ef90eaf27df1c","type":"inject","z":"77b37ced868e9673","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":640,"wires":[["3df9b0aa9707ec0d"]]},{"id":"3df9b0aa9707ec0d","type":"http request","z":"77b37ced868e9673","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://wttr.in/Berlin?format=j1","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":430,"y":700,"wires":[["c210afae3e1cb425"]]},{"id":"c210afae3e1cb425","type":"debug","z":"77b37ced868e9673","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":640,"wires":[]}]

The container is running on ubuntu 20.04 with latest docker-version. The NodeRED-Container uses version 2.2.2-16 so with nodejs-16. I had to move from nodejs-14 to 16 to use a specific nodered-package but even with the standard container and nodejs-14 i get this problem.

In addition i configured settings.js with log-level "trace" which unfortunately brings not more information:
25 May 13:37:50 - [error] [http request:3df9b0aa9707ec0d] RequestError: Bad response: 400

And also logging in the reverse proxy is not very useful:

nginx.1     | https://domain/ xx.xx.xx.xx - - [25/May/2022:13:37:50 +0200] "POST /inject/a19ef90eaf27df1c HTTP/2.0" 200 2 "https://domain/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0" "172.18.0.2:1881"
nginx.1     | _ 172.18.0.1 - - [25/May/2022:13:37:50 +0200] "CONNECT wttr.in:443 HTTP/1.1" 400 150 "-" "-" "-"

What also is done in docker-config for that container i set a ENV "http_proxy" to my subdomain.

Where can i see which header is configured by default for the http request node?

i found the solution.
Don't know why but i set the "http_proxy"-setting as described above.
But of couse the NodeRED-instance does not have to use a proxy. So i disabled that again and now everything is fine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.