You need to look at NGINX or some way for your application on PORT / 4000 to show up on port 80 for http or 433 for https. Port 80 / 443 is what your web browser is actually going to be able to see when you hit your IP address. A lot of people, including myself, use NGINX for port forwarding, proxying and load balancing. It's a small learning curve, but I recommend it 100x more than Heroku.
First you need to install NGINX inside your Ubuntu server (assuming you used a Ubuntu machine to host your site at Digital Ocean)
sudo apt-get update
sudo apt-get install nginx
Once that is done, you should be able to navigate to your IP in the browser and you'll see something about NGINX.
Now you can update the NGINX config file to your liking. You can use something like nano
or wget
to edit the config file. There's a ton of crud and comments in it, and I usually delete it all.
sudo nano /etc/nginx/sites-available/default
Your config can be simple for now. This is a boilerplate I picked up. Change the proxy_pass
to your correct port.
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Save that config file and you should be able to restart NGINX with the following command and cross fingers see your application by hitting your IP address in the browser:
sudo service nginx restart
As I was writing this answer, I found an article on this whole process here: https://www.sitepoint.com/configuring-nginx-ssl-node-js/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…