Reputation: 207
I only have ssh access to a server. It is ubuntu from amazon aws. I have uploaded my django project to it. When I run the command python manage.py runserver
or any variants of it, the server starts.
But as you know this will not allow me to access the web application from my browser which resides on a different network.
My question is
What would be the way that after I give my command to runserver either via django's development server or gunicorn. I may access it from the outside world by typing IP:8000 in my browser.
Secondly I would like to turn the access to IP:8000 on/off as needed. Like I may allow access for 5 minutes and then run a command to stop the access from outside world?
Upvotes: 1
Views: 1529
Reputation: 16753
Just in case, you want to run it on 80 port then you need root permissions
sudo python manage.py runserver 0.0.0.0:80
Upvotes: 0
Reputation: 8686
You can use http://localtunnel.me/, it's very very easy but you should use it only for development purposes.
Upvotes: 0
Reputation: 14331
You may also want to try the command:
python manage.py runserver [::]:8000
This will bind runserver to all available interfaces on your AWS VM. Please also note: runserver is really just meant for development. Running it in production is a bad idea.
Upvotes: 0
Reputation: 45293
You need assign a elastic IP address (EIP) on the aws ec2 instance, and allow the inbound traffic 0.0.0.0/0
to port 8000 from its security group.
Then you should be fine to access it from every where with EIP, such as http://54.12.23.34:8000
EIP may generate cost, if you stop the ec2 instance.
Upvotes: 1
Reputation: 2646
For accessing the django project else every where you have use the command
python manage.py runserver 0.0.0.0:8000
then You will be access it outside by giving the IP:8000
Note : the server provided by the Django is only for the development purpose only . If you want a permanent hosting you may like to use Apache or any server , where You can host your project. Hope This helps . :)
Upvotes: 1