How do I access my django app running on Amazon ec2?

前端 未结 2 1375
面向向阳花
面向向阳花 2021-02-10 16:46

So, I have looked around stack overflow + other sites, but havent been able to solve this problem: hence posting this question!

I have recently started learning django.

相关标签:
2条回答
  • 2021-02-10 16:51

    Make sure to include your IPv4 Public IP address in the ALLOWED_HOSTS section in Django project/app/settings.py script...

    0 讨论(0)
  • 2021-02-10 17:01

    You are running the app on port 8000, when that port isn't open on the instance (you only opened port 80).

    So either close port 80 and open port 8000 from the security group, or run your app on port 80.

    Running any application on a port that is less than 1024 requires root privileges; so if you try to do python manage.py runserver 0.0.0.0:80 as a normal user, you'll get an error.

    Instead of doing sudo python manage.py runserver 0.0.0.0:80, you have a few options:

    1. Run a pre-configured AMI image for django (like this one from bitnami).

    2. Configure a front end server to listen on port 80, and then proxy requests to your django application. The common stack here is nginx + gunicorn + supervisor, and this blog post explains how to set that up (along with a virtual environment which is always a good habit to get into).

    0 讨论(0)
提交回复
热议问题