[Django]-How to run Django Web app on port 443 and 80 linux – Ubuntu or Raspberry PI?

2👍

In ideal world you will need a web serve to talk to your Django.

Web server (port 80/443) -> gunicorn (wigs) -> Django (port 8000)

And if you just want Django development server to run on 80 then try

python manage.py runserver 0.0.0.0:80 

And make sure no other process is using port 80.

2👍

You do not talk to a Django app directly. While Django has a simple development server available via the runserver command, it is not meant for anything but development work.

What you want is to setup a WSGI server to run your app and a web server to accept actual user requests and proxy them to the WSGI. The commonly used WSGI servers (don’t worry about what WSGI is) are gunicorn and uWSGI. Both can be installed using PIP and you don’t have to install them as the same user as your app. Gunicorn is a bit easier to use, so I would recommend that one. The most common web server nowadays is Nginx.

Also, you should pack your application into a virtual environment, so you can pack it together with all the dependencies without relying on a specific system having everything installed.

Here is a somewhat dated guide on how to do this. It should be mostly accurate though and is a good place to start
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04

Leave a comment