NGiNX and uWSGI provides a great combination for Django-based web service on CentOS 7.  NGiNX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. We use uWSGI to integrate with NGiNX, because NGiNX does not support WSGI - uWSGI is a web server supports WSGI is used to forward requests from a web Server (such as Apache or NGINX) to a backend Python web application or framework. The below diagram is a common web service architecture based on Django, uWSGI, and NGiNX.

Gliffy Macro Error

You do not have permission to view this diagram.

The main function of NGiNX is a load balancer handling all the HTTP/HTTPS traffics from the internet and assign it to uWSGI, so all Django application will work as planned.

WSGI(Web Server Gateway Interface) is used to forward requests from a web Server (such as Apache or NGINX) to a backend Python web application or framework. There are different kind of WSGI variants:

  • WSGI is a Python spec that defines a standard interface for communication between an application or framework and an application/web server. This was created in order to simplify and standardize communication between these components for consistency and interchangeability. This basically defines and API interface that be used over other protocols.
  • uWSGI provides a full stack for developing and deploying web applications and services. The main component is an application server that can handle apps of different languages. It communicates with the application using the methods defined by the WSGI spec, and with other web server over a variety of other protocols.
  • uwsgi us a fast, binary protocol implemented by the uWSGI server to communicate with a more full-featured web server. This is a wire protocol, not a transport protocol. It is preferred way to speak to web servers that are proxying requests to uWSGI.
  • nWSGI is a .NET implementation of the Python WSGI specification for IronPython and IIS.