Front-Ending an app server on AWS EC2 - amazon-web-services

I have 2 instances set up in EC2. One is running nginx and has an association with the elastic IP address, so its publicly accessible.
The other doesn't have a web server but has a RESTful server running on port 8080.
Both belong to a security group with these rules:
Ports Protocol Source MongoDB-2-2-2-AutogenByAWSMP-
22 tcp 0.0.0.0/0
80 tcp 0.0.0.0/0
8080 tcp 0.0.0.0/0
If I understand that right then port 8080 should be open.
If I ssh onto my web box (with nginx running) I'm trying to test access to my RESTful server on the other instance:8080, so I tried:
curl http://10.151.87.76:8080/1/tlc/ping
curl http://ip-10-151-87-76:8080/1/tlc/ping
curl http://ip-10-151-87-76.ec2.internal:8080/1/tlc/ping
All of these gave me "couldn't connect to host" errors.
If I log onto the RESTful box directly and do the following, it works.
curl localhost:8080/1/tlc/ping
So I know my service is up and healthy.
Any ideas why I can't see port 8080 from the other instance are appreciated.

Make sure instances are in the same availability zone. If not, you may need to access the instance by public DNS name (something like ec2-XXX-XX-XXX-XXX.YYY.amazonaws.com).
Make sure 10.151.87.76 is the correct IP. Note that this will probably change after the instance is stopped and started again.
Make sure your headless service is publicly available -- it may listen on localhost:8080 only but should listen on 0.0.0.0:8080. Try nmap 10.151.87.76 -p 8080 from other instance, it should list 8080 as open port.

Make sure your headless service is publicly available << so this is the reason. What web server are you using for REST API? If it is Apache, make sure config says Listen 8080, not Listen 1.2.3.4:8080. If it is standalone app, make sure it can listen on all interfaces -- some clients will listen on localhost by default. – hudolejev 54 mins ago
This! Buried deep (deep) within my code was a piece of the server wired to "localhost". Changed that to key off hostname and all was well! Happy.

Related

Cannot access from browser on port 3000 even though added to incoming

I created an Ubuntu EC2 instance. I then am running a node.js express server on port 3000. Doing a curl to http://localhost:3000 gives me the HTML string I expect.
However when I try to access from the browser with the Public DNS (IPv4) which is ec2-18-221-209-77.us-east-2.compute.amazonaws.com. It is not loading. The browser spins forever at http://ec2-18-221-209-77.us-east-2.compute.amazonaws.com:3000.
I did put in my security group inbound rules, 3000 for Custom TCP and I set the source to anywhere. screenshot - https://i.imgur.com/2U24qUn.png
I also did netstat -tulnp and it seems :::3000 is open but only on tcp6, do I need it in TCP too? How can I do this? Screenshot - https://i.imgur.com/9jZVZH0.png

AWS EC2 Windows Server 2016 expose port 80

What I'm trying to do is access my webserver on my EC2 from the outside.
Here's what I've done so far:
I've opened all Incoming Traffic to anywhere both for IPv4 and IPv6 in the EC2's Security group
Disabled the firewall from the Control Panel in the EC2 for both public and private
Started my webserver on port 80
From outside the ec2:
I can ping the EC2 succesfully
If I run telnet <my ec2 ip> 80 I get telnet: Unable to connect to remote host: Connection refused
If I run nmap <my ec2 ip> port 80 is not listed
From inside the ec2:
I was able to connect from localhost:80 in EC2's browser
If I ran netstat -aon it shows it is listening on port 80
Make sure that your web server is bound to the external network interface.
Using 0.0.0.0 will ensure that connections can be made from any interface. On the other hand, using 127.0.0.1 (localhost) would have behavior like what you describe, where you can connect to the web server locally, you can reach the host externally (e.g. via ping) but cannot connect to the web server externally.
Is your EC2 instance in a custom VPC? If so, look at attaching an Internet Gateway to the VPC and update the route tables associated with the subnet in which your instance is running.
For this answer I am assuming that you are using IIS as your web server.
1) Start Internet Information Services (IIS) Manager.
2) Expand the left hand panel "Connections" and locate your web server under "Sites".
3) Select your web site. In the right hand panel click on "Bindings".
4) A "Site Bindings" dialog box will open.
5) Under the tab "IP Address" make sure that an asterisk displays so that the server binds to all network interfaces on startup.
5) In the right hand panel under "Manage Website" click "Restart".

AWS public DNS for ubuntu instance is not accessible from the browser

I am relatively new to AWS and I've been looking at quite a few tutorials for the past couple of days trying to figure out how to make my AWS ubuntu instance accessible from the browser.
What I've done:
1st: I configured security groups to accept all traffic for ssh, http, https just to see if the public DNS listed in the instance is accessible.
2nd: I changed the IP of my instance to an elastic IP
3rd: I wrote a simple node.js file that listens on port: 9000 and console.logs 'hello world'
For some reason ssh works, and I can run my node.js file, but agina I cannot access the remote instance from the browser.
Any help would be greatly appreciated since I've been on this for a couple of days
Thanks!
Thank you everyone for the quick responses!
My issue was I did not include a TCP rule to my specific port. Now I am able to access that port via ec2-DNSNAME:9123.
And, just to clarify, if I want to host that DNS for all traffic I should specify 'anywhere' for the TCP rule, correct?
I configured security groups to accept all traffic for ssh, http, https
In security groups, "HTTP" does not mean "HTTP on any port"... it means "any traffic on TCP port 80" -- 80 being the standard IANA assigned port for HTTP.
Security groups are not aware of the type of traffic you are passing, only the IP protocol (e.g. TCP, UDP, ICMP, GRE, etc.) and port number (for protocols that use port numbers) and any protocol specific information (ICMP message types).
You need a rule allowing traffic to port 9000.
Firstly go to your EC2 and see if curl http://localhost works..
Also, if you are exposing your nodejs on port 9000 ; did u open 9000 also on security groups or not ?
Few things to check:
Security groups
Subnet NACLS (these can function as a subnet level
firewall, but unless you've messed with these they should allow all
traffic.)
On the server if you run netstat -na | grep <PORT> do you see your
application listening on the correct ports?
You may also check your system for a firewalls that could be short circuiting the requests.
If the above doesn't point you towards where your issue is you can grab tcpdump and filter it just for requests coming from your web browser (e.g after installing tcpdump -vvn host 10.20.30.40 port 8000 Substitute your ip and port). This will let you know if you're running into a network issue (Packets aren't reaching the server) or if its something with the app.
I'd also recommend using IP addresses while doing your initial troubleshooting. That way we can establish it is not network/server configuration before going into DNS.

My AWS ec2 instance is running on ec2-xx-1xx-xxx-24.compute-1.amazonaws.com:8000. how do i make it run on ec2-xx-1xx-xxx-24.compute-1.amazonaws.com

My AWS ec2 instance is running on ec2-xx-1xx-xxx-24.compute-1.amazonaws.com:8000. how do i make it run on ec2-xx-1xx-xxx-24.compute-1.amazonaws.com
I am using Gunicorn server server and it is a Django application on Ubuntu server
You can configure the same via virtual host in httdp.conf with redirection rule or you can do the same with ELB in which you can mention the request comes on 80 and ELB will forward the same on 8000 port.
This is a two step problem:
You have to configure Django to listen on the right port, and you also have to modify the security group attached to your instance to allow connection on port 80.
You can either allow access from anywhere or from a specific IP/Range of IPs.
An other solution is to create an ELB and configure it to listen on port 80 and send the traffic on port 8080.

Can't connect to EC2 instance via web browser

I'm a total newbie when it comes to servers and EC2 but I have an EC2 instance running which was stopped and restarted. Since that I haven't been able to connect via a web-browser to the site but can connect via SSH. Are there any ideas why this could be the case?
Here is the debug checklist:
Check your server, make sure it is up and running in AWS management console.
Check port security setting, from your local machine. If it is close open it in security group.
telnet your_ip 80 # Check http port
telnet your_ip 22 # Check SSH port
Check your web server, Apache, Nginx, etc. If you cannot find your process, start it.
ps -ef | grep -e nginx -e httpd -e apache
Check your virtual host config, make sure you web server is listening to port 80 (http) or 443 (https).
Run chkconfig and make sure your web server will start as a service.
Check the security group in your instance property, it is probably allowing only SSH (default), you may want to add a inbound rule allowing HTTP traffic.