2

I have a React app and two Node Express (REST API) processes running under http (Apache2) on a DigitalOcean Ubuntu 20.04 Droplet. The React app runs on port 80 while the Node Express apps run on port 4000 and 4001 respectively.

All instances of http have been replaced with https in my code. However, ports 4000 and 4001 are not secure ports like 443 is. I have Certbot installed with no errors.

What is the recommended way to 'migrate' from http to secure https in this case? Will I need to set up a reverse proxy on the Apache2 web server?

Rayner
  • 128
  • 9
  • You're doing it wrong. You should setup a process manager (like [PM2](https://pm2.keymetrics.io/)) to handle the node applications and then use HTTP proxy to expose those apps ports and bind them to domains and locations using `ProxyPass` and `ProxyPassReverse`. Check this nice article [Set Up a Node.js App for a Website With Apache on Ubuntu 16.04](https://www.ionos.com/digitalguide/websites/web-development/nodejs-for-a-website-with-apache-on-ubuntu/). – Christos Lytras Jan 16 '21 at 17:07
  • @ChristosLytras I am using PM2, works great. Nowhere does it show in the article you linked how to get both Node processes running under https. Still searching for the answer. – Rayner Jan 17 '21 at 04:19
  • The domain you will bind the PM2 process will have an SSL certificate using Appache SSL module (`sudo a2enmod ssl`). In your question you're trying to match application ports directly to be served. If you're using PM2, then you don't have to change `http` instances to `https`, because PM2 will bind them using `http` and then Apache SSL module will proxy the PM2 processes to the HTTP server. There are countless articles regarding how to setup SSL in apache. Create a domain that supports SSL using `...` and then use `ProxyPass / http://localhost:4000/`. – Christos Lytras Jan 17 '21 at 11:17

0 Answers0