0

Here's my situation: I followed this tutorial to host my website using Bitnami MEAN-Image on an Amazon EC2 instance - https://scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1. Then, I bought a domain name and set up my elastic IP address on my EC2 instance, and I've linked the domain and instance. If I run my app on port 3000 (npm start), I can see the app by going to mydomain.com:3000, but if I run my app on port 80, or if I don't run my app at all then I am taken to the default Bitnami MEAN page when I go to mydomain.com or mydomain.com:80. How do I get my app to appear on mydomain.com without specifying the port?

Editing to ask this; even without using my purchased domain name, is it possible to make my EC2 instance public dns default to my app's main page instead of defaultin to the Bitnami MEAN home-page?

Forest Hughes
  • 143
  • 1
  • 3
  • 12

2 Answers2

1

If you have installed the Bitnami MEAN Stack, you will have your Apache server running on port 80, and it serves the default page located at /opt/bitnami/apache2/htdocs.

If you want Apache to serve your application by default, you can do it following the steps below:

  • Start your application in your port, for instance, the port 3000.
  • Go to your /opt/bitnami/apache2/conf/bitnami/bitnami.conf and add the following lines within your default Virtual Host configuration. It should look like this:

<VirtualHost default:80>

...

ProxyPass / http://127.0.0.1:3000/

ProxyPassReverse / http://127.0.0.1:3000/

...

</VirtualHost>

Now, you should be able to access your application at http://your-ip/

Francisco Ortiz
  • 508
  • 3
  • 11
0

You have to redirect your port 80 to 3000 so whenever they enter the domain or the ip, it gets to port 80.

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

use this and this should redirect the port 80 calls to 3000

slfan
  • 8,950
  • 115
  • 65
  • 78