Search code examples
apachedockersslnode-redportainer

How to use Apache to redirect requests for Node-Red?


I'm running in AWS a Ubuntu with a docker server (managed by Portainer) with this two running containers:

1 - NodeRed (Serving my APIs)
2 - Apache (Hosts the site that consumes the APIs from NodeRed above)

I've configured a domain to this server and setted apache to work with SSL. The apache is running ok with my site through HTTPS, but the problem is that the NodeRed (that runs in port 1080) is not configured to run in SSL. This causes a malfunction in my website since that my API endpoints are being running under HTTP and being blocked by the browser due security reasons.

The question is: is there a way to create some kind of "mapping" in apache that receives the request from HTTPS and redirect to the NodeRed in HTTP (the two are running in same server)?

My idea is to create a subdomain like https://api.mysite.com that sends the request for apache and then apache redirects it to my NodeRed. Is that possible?


Solution

  • There is no need to expose the API to the outside world if you don't want to. Since your apache is running correctly and both containers are running on the same host, just use proxy to forward API requests to the API container.

    You can achive this by add two lines to your apache config i.e.

    ProxyPass /api/ http://127.0.0.1:1080/
    ProxyPassReverse /api/ http://127.0.0.1:1080/