Django AWS Elastic Beanstalk Deployment Successful but site not responsive - python

I'm trying to deploy my own API. I am using Django and the Django Rest Framework. I have uploaded my Django via Elastic Beanstalk Command Line Interface via eb init and eb create.
I am following this tutorial and have followed all of the steps:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
I have successfully created my environment and uploaded my app:
However, when I hit up the url via eb open, this shows:
How do I debug something that tells me nothing is broken? I feel like something is off. My intuition tells me it has to do with me trying to serve my API over SSL. I currently have my Django app redirect all http requests to https. Do I have to run manage.py runsslserver? Do I need to install any environment things from my requirements.txt file?
EDIT: Normally when I run python manage.py runsslserver, I'm greeted with this on localhost. I have set up an api-root and expected to see that when I hit the EBS url.

Related

How to run flask CLI command in AWS Elastic Beanstalk

I have my flask server running in AWS Elastic Beanstalk, however, I want to run some custom flask CLI commands that are listed in commands.py file of my repository. Previously when my server was hosted in Heroku, I was able to run these commands through the Heroku console, however I'm unable to figure out how to run these commands in Elastic Beanstalk or even go inside of the beanstalk environment and run my custom flask commands through the command line.
I tried using the eb cli but that seems to only allow me to mainly deploy, terminate, open the Elastic Beanstalk environment but nothing in the eb cli seems to allow me to even run flask --help inside the environment
even go inside of the beanstalk environment
If you use eb cli, then it would be eb ssh to ssh into your instance.
I'm unable to figure out how to run these commands in Elastic Beanstalk
Generally you would create .ebextentions config files with commands or container_commands to run the actual flask commands.
There are also other options, such as platform hooks.

Unable to runserver when I close my SSH connection with AWS EC2

Hope anyone with these areas of expertise can help me.
Basically, I am trying to run my Django project inside the EC2 instance in Amazon Web Service. I have placed the files and tried to run the server with
python3 manage.py runserver 0.0.0.0:8000
The steps I used to configure my EC2 is by referring to this website: https://medium.com/saarthi-ai/ec2apachedjango-838e3f6014ab. I followed all the steps and I was able to deploy my project.
However, once I close my SSH connection, I won't be able to access the website anymore. Is there a solution to this?
Regards,
YX
When you exit(close connection) from SSH. It will close all user activity which are running on.
So you need to deploy your Django project on server with specified port. So project have accessible anytime from any where as per defined policy.
Please follow the following link to deploy your django project on ec2.
you need to configure Gunicorn with Nginx to host your
project on EC2
https://www.pythoncircle.com/post/235/how-to-setup-django-app-on-ec2-instance-aws/
If you have experienced person on AWS than you need to follow following instruction.
https://aws.amazon.com/getting-started/projects/deploy-python-application/
Thanks

Flask web application deployment in AWS

So when i run the application in amazon instance it tries to get the data from google inthis image
when it goes to the callback this is the output i get
I have run an python application with google Oauth2 and ran it successfully locally. Gunicorn serves http and google Oauth2 requires hhtps. I locally used certificates i have generated and it worked successfully, but when i try to deploy in Amazon Ec2 instance, it doesn't work. Did anyone face such kind of problem? will using nginx be helpfull in that case?

Can boto3 be used for deployment of an ElasticBeanstack application?

I've successfully been able to create and deploy ElasticBeanstalk environments using the eb cli tool, however now I'm trying to get my head around boto3 and deploying code.
But I can't for the life of me figure out how to actually deploy an app (or whatever the package containing the .ebextensions folder is called) using boto3.
Using eb cli, running eb deploy packages up that directory and uploads it all to AWS, with any changes to the .ebextensions to deploy the app.
However the docs for elasticbeanstalk for boto3 include:
create_application() - just makes the app specification, no uploading
create_application_version() - pulls a link to an app version, but I can't make one or upload one
create_environment() - makes the broader environment, still no good.
How do I actually deploy an app using boto, or am I stuck with eb cli?

Django app deployment on shared hosting

I am trying to deploy a django app on hostgator shared hosting. I followed the hostgator django installation wiki and i deployed my app. The issue is that i am getting a 500 error internal page when entering the site url in the browser. I contacted the support team but could not provide enough info on troubleshooting the error Premature end of script headers: fcgi.This was the error found on the server error log.
I am installed django 1.9.5 on the server and from the django documentation it does not support fastcgi.
So my question 500 error be caused by the reason that i am running django 1.9.5 on the server and it does not support fastcgi. if so do i need to install lower version of django to support the fastcgi supported by hostgator shared hosting
First i thought the error was caused by my .htaccess file but it has no issue from the what i heard from support team.
Any Leads to how i can get the app up and running will be appreciated. This is my first time with django app deployment. Thank you in advance
I know this is a while as to when i asked the question. I finally fixed this by changing the hosts. I went for Digital Oceans (created a new droplet) which supports wsgi. I deployed the app using gunicorn (application server) and nginx (proxy server).
It is not a good idea to deploy a Django app on shared hosting as you will be limited especially installing the required packages.
Many hostings today that support python use Phusion Passenger and I have been able to deploy Django on it successfully. Before I share the procedure, let me mention that I faced a lot of problems in doing this and now I have the solution to all of them. I have already written a step by step guide on my blog here to deploy a Django app on shared hosting.
Start a new python app in cpanel. Specify the url where you want the app to be and the folder where you want to put the contents of the app. Set the Application startup file to passenger_wsgi.py and the Application entry point to application.
Copy the command to enter the virtual environment and run it via online terminal in CPanel or SSH.
Install version 2.1 of Django (latest 2.2 will not work) pip install django==2.1
Upload your django project to the folder you specified while setting up the app. There will be a passenger_wsgi.py file in that folder. Edit it and enter the following code: (replace myapp with your application name)
from myapp.wsgi import application
Edit the settings.py file and add the url of your appp to the ALLOWED_HOSTS list.
Set up the MySql database
Configure the path for static files in the settings.py and run python manage.py collectstatic
Again go to Setup python app in cpanel and restart the app.
As you say, Django 1.9 does not support FastCGI.
You could try using Django 1.8, which is a long term support release and does still support FastCGI.
Or you could switch to a different host that supports deploying Django 1.9 with wsgi.

Categories

Resources