Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need uwsgi for hosting Django on nGINX

Lets see:

Django is WSGI compatible. WSGI is Web Server Gateway Interface

Now, Nginx is a server. So we should be able to communicate with Django. So then why do we need uWSGI in between??

All say that uWSGI is a server which speaks wsgi protocol.

Then what is uwsgi protocol. How does it differ from WSGI (which is a protocol/specification)

And again, why do we find the combination Django + uWSGI + Nginx ??

Cant I speak WSGI between nginx & django?? Coz WSGI itself means to be an specification between WebServer (nginx) and Web Applications (django)

like image 770
Kartik Rokde Avatar asked Nov 12 '22 21:11

Kartik Rokde


1 Answers

WSGI is specifically a Python interface, whereas Nginx is a general webserver. So at a minimum you need something between Nginx and Django that translates the standard http request into a WSGI one.

uWSGI is just one of several popular WSGI servers. Others include gunicorn and mod_wsgi (an Apache module which necessitates having Apache installed too). uWSGI happens to be my preferred one and nginx now has native support for its protocol, so you won't go to far wrong by using it.

like image 161
Andrew Ingram Avatar answered Dec 25 '22 11:12

Andrew Ingram