I have setup Nginx on AWS EC2, Ubuntu 20.04 server. I used below commands:
# add nodejs 10 ppa (personal package archive) from nodesource
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
# install nodejs and npm
sudo apt-get install -y nodejs
# install nginx
sudo apt-get install -y nginx
echo "
----------------------
UFW (FIREWALL)
----------------------
"
# allow ssh connections through firewall
sudo ufw allow OpenSSH
# allow http & https through firewall
sudo ufw allow 'Nginx Full'
# enable firewall
sudo ufw --force enable
Also, I have proper ports open as shown below image
But still, I am not able to access the URL http://IP_ADRESS.
What could be issue?
2
Answers
Did you verify that if you are using an IP, it is the elastic IP assigned to the EC2 instance and not the private IP? Because sometimes some people use the private IP thinking that they will be able to access when in fact they should use the DNS that is created for the Ec2 instance.
Then you should also verify if your Ec2 instance is within a VPC / subnet that has the necessary configuration to expose itself to the internet, because if not, even if you have an SG with the port open, you will not be able to access it.
Check that for the security group used for the EC2 instance, HTTP and HTTPS have ports 80-HTTP and 443-HTTPs allocated.
Install and configure ngix on your EC2 instance (https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04), this link may be helpful as well as the
sudo systemctl enable nginx && sudo systemctl start nginx
command suggested by CherryDT that can be executed after ngix installation.When you access the assigned IPV4 check if it works with
http://
in front of the IP and after you have configured the SSL (https://medium.datadriveninvestor.com/nginx-server-ssl-setup-on-aws-ec2-linux-b6bb454e2ef2) you can try to access it withhttps://
.