Elastic Beanstalk 504 Gateway Timeout Error - Django - django

I recently completed the W3schools.com Django Tutorial. I followed it step by step. Everything works as expected locally. I also created and connected a PostgreSQL database on Amazon RDS to my app. Eventually I deployed the Django application to Elastic Beanstalk. Finally I visited the website and the homepage works, including 5 items added to the database during the tutorial which was migrated from the tutorial to the Amazon RDS. Unfortunately, neither the Django admin panel nor a simple subdirectory of the website are accessible. I get a 504 Gateway Time-out error. I don't know why. It is not clear from the logs what the issues might be. I am thinking it could possibly be a configuration file error or an incorrect value of settings.py on Django's side. Any help would be greatly appreciated.

Related

How to restrict random (unidentified) requests to a DRF based API hosted on an AWS EC2 instance?

I'm running a DRF based API deployed with Docker on an EC2 Instance. After a few days of deploying I started facing an issue where the API stopped responding properly and that's when I noticed unidentified requests to my application, and that too at huge volumes. An example screenshot is attached below:
Although all these requests ultimately return 503 because these pages do not essentially exist, I want to take steps to restrict such requests.
FYR, I have a frontend (React JS Based) app running on AWS Amplify which consumes this API. I was looking for ways to restrict inbound requests to this EC2 to only the Amplify app, but realised that Amplify doesn't offer a Static IP of it's own. Any solution to that would also be appreciated.
UPDATE:
I have also put my domain name in the ALLOWED_HOSTS setting in my DRF, I am still receiving such hits.

502 bad gateway django elastic beanstalk

I got the django app deployed with elastic beanstalk on aws, I setup postgresql for it as well to work with one on aws. Unfortunately, following
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
I am getting 502 bad gateway after
eb open
I'm not really getting any errors, my app runs on local. I'm using the debug server, I also managed to run it on waitress. I was reading the oceans of info online and the only thing I can think of - do I need to actually deploy to a production server locally or can I just use EC2 for that? I'm learning about AWS as I go, so sorry if I'm not understanding something here :)
Thank you!

How to send a flask application to AWS Elastic Beanstalk?

I am trying to deploy my website to Elastic Beanstalk in the console from AWS. The website structure is working perfect locally in my computer and has this structure:
- app.py
- Static --------- css --------- style.css
js --------- autocomplete.js
otherfiles.js
- Templates ----- index.html
the application app.py is an application in Flask sending the values of the variables to the index and the javascript files . I would like to make the webpage work in AWS, and, since the app.py has to be running all the time 24 hours, I have thought the best option is AWS Elastic Beanstalk. What I did was:
I created the environment
I uploaded my project in the console from AWS Elastic Beanstalk. According to what I read in other post from Stackoverflow, the best idea, is to upload the whole project on a zip file and then unzip it. I did it but all that I got is the message "Environment health has transitioned from Degraded to Severe. 100.0 % of the requests are failing with HTTP 5xx. ELB processes are not healthy on all instances. ELB health is failing or not available for all instances. Impaired services on all instances."
Does anybody know if I am heading in the right direction?
Thanks a lot
Check the beanstalk logs, you'll likely find information there that will help you determine what the problem is. I had a similar issue recently (although I was using the command line interface and not the console) and it turned out beanstalk was looking for "application.py" by default.

Django project on AWS elastic beanstalk always has health "severe" and CPU load 100%

I've developed a web app using python and django and have deployed it to AWS elastic beanstalk and have been having problems.
I followed this tutorial on how to deploy and followed the steps:
http://www.1strategy.com/blog/2017/05/23/tutorial-django-elastic-beanstalk/
The deployment worked for a couple of days and was reachable on the url given by elastic beanstalk, but today it stopped working and I noticed some weird log entries.
My health is always "severe" and my CPU load is always at 100% (user: 90+%)
here are the logs from elastic beanstalk:
https://pastebin.com/1KvSP6SJ
What is this /cpv, and why is there so many requests for it? At one point
there were +200 r/sec.
I also don't know what cpvfeed.50onred.com is. it is not my domain, nor am I
using any kind of advertising site.
Is this some sort of attack, or am I doing something wrong?
My website is not working and is giving me HTTP 408 and HTTP 504 errors.
How can I make my site reachable again, and bring the CPU down to a normal value. I should only have about 3-4 users at the moment, so I don't know where these +200 requests per second are coming from.
Please let me know if you need any more information.

how to run django application on browser which is hosted on aws

I have created a website based on Django framework. I want to run that website through the amazon aws. I have already created an instance on aws and downloaded the code from git in the instance.
The problem I am now facing is I am not able to understand how to run the website made through django on the browser. I have read some blogs about using nginx but is there a way to do it just with wsgi .
If I directly type the attached ip to the browser with the port, it doesnt show anything. Please help me with the deployment.
Thanks in advance