How to access Flask app using Amazon AWS - amazon-ec2

I'm trying to run a Flask application on Amazon Linux AMI, so I do the following:
>>> cd /var/www/testapp
>>> python test.py
INFO:werkzeug: * Running on http://127.0.0.1:5000/
Looks good so far, and I'm currently using localtunnel to access the site, so:
>>> localtunnel 5000
Port 5000 is now publicly accessible from http://xxxx.localtunnel.com ...
So localtunnel is doing something that makes test.py running on port 5000 publicly accessible. How do I do this on my own?
I used ifconfig and tried different combinations of the ip addresses it gave at port 5000 in my browser, but none of them worked.
EDIT: I tried attaching an elastic IP to the instance and accessing it through there but it's still not working.

The most likely answer, without knowing any other information, is that your security group for this instance needs to be opened for port 5000.
If that is not the case, we will need more information, logs, etc.

Related

How do I access 127:.0.0.1:5000 on Ubuntu Server 16.04 LTS (HVM), SSD Volume Type

I just started studying flask and built a toy website to see how well I am doing. I have a flask website built in python 3.6 and I have tested it on my windows computer and everything goes very well. Now I want to host the website on an ubuntu ec2 instance. But first, I am testing if everything runs well on my ec2 instance and am stuck at trying to access port 5000 on my ec2 instance My app is currently serving on port 127.0.0.1:5000 of my linux server. I have tried to connect to my.ec2.public.ip:5000 and my.ec2.private.ip:5000 with no success. Could someone help me? Thanks.
By default, your Flask app will listen only on localhost, you need to add host arg in run in make it listen to your actual server's IP.
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80) #or whatever port you want your app to listen to.
To edit the security group of your instance, go to the EC2 instances page and slide to your extreme right, you will have Security Group column. Here click on the security group written in your instance and edit to add the port that you want to open.
By default a new AWS instance would not allow port 5000 to be accessed, so you will need to modify the security group to allow access on that port. You do this thru the AWS console.

How to use run deck service from local browser using up address?

I have installed rundeck in docker using ec2 instance.
When I run the image and start rundeck. It's fine.
Lynx http:localhost:4440
Us able to show rundeck dashboard.
But, how can I access this rundeck from Windows browser?
I tried using address but connection refused.
In order to access this from outside for your setup, you might have to ensure the following things:
Ensure that host server (ec2) is forwarding ports to the docker container. You should have used -p or -ports when launching the container for this.
Test: From your EC2 instance, you should be able to access: http://localhost:4440
Ensure you have a public IP assigned to your EC2. You should be able to see that from your aws ec2 console: http://console.aws.amazon.com/ec2
Ensure that your security group(s) for that instance has InBound connections to accept 4440 from your IP or rest of the world.
After this, your http://:4440 should work.
I hope I got your question correct.
Let me know how it goes,
Thanks,
Anoop

How to access Docker web app from host OS?

I've followed the tutorial on the docker.io website here:
http://docs.docker.io/en/latest/examples/python_web_app/
How would I access this app from a browser on my host OS?
Docker Remote API provides a way of accessing your Docker images and containers and performing many operations on them, through your Browser.
Here is the link for Docker API v1.6 Documentation
Hope it helps.
The tutorial explains how this works:
WEB_PORT=$(sudo docker port $WEB_WORKER 5000)
Look up the public-facing port which is NAT-ed. Find the private port used by the container and store it inside of the WEB_PORT variable.
# install curl if necessary, then ...
curl http://127.0.0.1:$WEB_PORT
Hello world!
Access the web app using curl. If everything worked as planned you should see the line “Hello world!” inside of your console.
Inside the container the application is listening on port 5000. This is translated automatically to an external port number accessible outside of the container. This makes sense because it allows multiple copies of your application to coexist on the same machine, each mapping port 5000 to a uniquely accessible port number for each app instance.
The documentation on port redirection has more details.

Can't get Amazon EC2 instance work

I am trying to setup an amazon ec2 instance for first time.
I've created one with ubuntu 10.4, managed to connect to ssh and installed mongodb, mysql, php and apache which need for my proyect(also python but it is already setup).
Then I associated an elastic ip to the instance, but when I try to open the IP, I can't. It gives timeout.
Could it be that the apache root is not where I think it is?(/var/www/)
You need to check the security group that is associated with the instance. Make sure that you open up port 80.
Also make sure that apache is started, and configured to start on boot.
If you're logged in, you should be able to use wget localhost to verify if apache is serving up pages.

Getting a cherrypy Hello World running on EC2 instance

I am trying to do a simple proof of concept on a new EC2 instance in which I run the "Hello World" tutorial code from the CherryPy distribution.
CherryPy launches successfully, and a wget run directly on the EC2 instance successfully retrieves the Hello World page. However, trying to access the same page from my own machine results in a "could not connect" error.
CherryPy is running on port 8080, and my EC2 instance is set up with a security group that ought to be allowing traffic from anywhere to connect to port 8080.
Here is my CherryPy tutorial.conf:
[global]
server.socket_host = "127.0.0.1"
server.socket_port = 8080
server.thread_pool = 10
I have tried connecting to the web server using both the public DNS listed in the AWS management console, as well as by setting up an elastic IP; neither allows a successful connection.
Any guidance would be greatly appreciated.
Set the socket_host to the server ip or '0.0.0.0' for external access.

Resources