Is it possible to use NodeRED as functioning LAN https server?

I'm currently running a python https webserver to handle requests from Scratch 3 to control GPIO pins

I'm wondering if I could use NodeRED as an alternative?

Hi @cymplecy

yes - the HTTP In nodes can be used to make flows triggered by http requests - https://cookbook.nodered.org/http/

I know it can handle http requests but I wondering whether it handle https requests with some locally generated SSL certs?

Ah sorry - didn't realise it was the https bit specifically. Yes, you can get node-red to accept https requests - search your settings.js for https

1 Like

Ta -I'll have a play then :slight_smile:

You can also get a reverse proxy like NGINX to terminate the SSL, which may be more secure if you plan on making it externally accessible from the Internet.

Pure LAN application but thanks :slight_smile:

Seems that I might not need an HTTPS server in the first place!

I've been redirecting Scratch 3 translate calls to a python HTTPS server but wanted to try out making a NodeRED one instead

I had believed that once a browser makes an HTTPS request, if it got redirected, then the alternative server also needed to be HTTPS as well but seemingly not :slight_smile:

I think I got the (wrong) idea from trying to make a call from a modified .js script running on the Scratch HTTPS site to a http server and failing - so I just assumed that re-directs also needed to go to an HTTPS server

Happy to be wrong :slight_smile:

Spoke too soon :frowning:
Everything worked without https when Scratch 3 running in browser on same machine as NodeRED but when trying to use across a LAN - it wanted webserver to be https again

So I edited my settings .js like this

...
// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
var fs = require("fs")
...
    https: {
        key: fs.readFileSync('ca.key'),
        cert: fs.readFileSync('ca.pem')
    },
...
    httpNodeCors: {
        origin: "*",
        methods: "GET,PUT,POST,DELETE"
    },
...

(my ssl certs are available here https://github.com/cymplecy/scratch_gpio/tree/v8 - stick them into /home/pi/.node-red)

I'm thinking - can I get away with a double hop?
i.e NodeRED http server on main computer localhost - communicating on side channel to NodeRED on the Pi - and relaying back again

......