user2898916
user2898916

Reputation: 13

How can I access Django Admin Site on Amazon EC2 Instance?

So for a school project, I have to follow the steps in the "Writing your first Django App" Tutorial on Django's website, but we're supposed to have it on our EC2 instances, which are running Ubuntu 12.04.

In the tutorial, it says:

Now, open a Web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/. You should see the admin’s login screen:

That must mean I have to access the EC2's local domain on my computer, right? How should I go about doing this?

I've tried (with my correct address in the x's) "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/home/admin/", "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/admin/", and even using the user's directory I'm using "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/user/admin/".

I put the project in the user's folder, so it's in /home/user/my_django_project/

I've accessed and used EC2 successfully before by putting PHP and HTML projects in the /home/user/public_html/ folder, but I have no clue what to do for this.

Upvotes: 1

Views: 1825

Answers (2)

user2729904
user2729904

Reputation: 31

  1. Run the following command in the Django application folder:

    python manage.py runserver 0.0.0.0:8000
    
  2. Add a rule to your Security Group to allow Inbound TCP through port 8000. You can use a Custom TCP Rule to specify that only port 8000 be allowed in.
  3. Open your browser and go to the following link:

    http://<EC2_ADDRESS>.amazonaws.com:8000/admin/
    

The admin page should now load and you should be able to see the GET requests from your local computer on your Amazon server. e.g [29/Mar/2015 03:35:24] "GET /admin HTTP".

Upvotes: 3

EWit
EWit

Reputation: 1994

I guess you run Django via the manage.py runserver command? If so Django is currently only listening on 127.0.0.1. Start django using

manage.py runserver 0.0.0.0

in order for it to listen on all IPs. You should then, if configured properly, be able to reach it via "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com:8000/admin/".

Upvotes: 1

Related Questions