# Nginx and uwsgi

**URL:** <https://www.ruby-forum.com/t/nginx-and-uwsgi/220480>\
**Category:** NGINX\
**Created:** [June 11, 2012, 3:35pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480 "2012-06-11T15:35:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 11, 2012, 3:35pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480/1 "2012-06-11T15:35:27Z")

</div>

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![BiswasS\_Pinakee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7bcc69/32.png) [@BiswasS\_Pinakee](https://www.ruby-forum.com/u/BiswasS_Pinakee)\
**Post date:** [June 11, 2012, 3:48pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480/2 "2012-06-11T15:48:54Z")

</div>

> We are new to nginx (have prior experience with Apache) and have  
> downloaded  
> 1.2.1. The OS is CentOS.
> 
> We are not sure how uwsgi works with nginx:
> 
> 1. 
> 
> ```
> Do we have to start uwsgi as a separate process?
> 
> ```

Yes, but remember: uwsgi is a communication protocol (like http or  
fastcgi), uWSGI is the application server.  
You need to start uWSGI, and configure nginx to speak with it with the  
protocol of choice (uwsgi, http or fastcgi)

> 1. 
> 
> ```
> There is no option/directives for loading modules in nginx (as it
> 
> ```
> 
> is there in Apache).

nginx does not work in that way, but it should be not a problem for you  
as  
upstream modules (http, fastcgi, scgi, uwsgi) are compiled in by  
default.

> 1. 
> 
> ```
> I couldn't find a good documentation on the uwsgi based
> 
> ```
> 
> directives.  
> The one in nginx wiki is confusing.

you need nothing particular:

include uwsgi\_params;  
uwsgi\_pass ;

all the other options are for fine tuning.

I suggest you to start from here:

> **[The uWSGI project — uWSGI 2.0 documentation](https://uwsgi-docs.readthedocs.io/en/latest/)**

> Since nginx I think works as a reverse proxy where it forwards HTTP  
> requests  
> to the uwsgi process, how about using something like Cherrypy or  
> PasteHTTPserver? Would there be any difference?

you can proxy nginx to whatever you want/need if the backend speaks one  
of  
the supported protocol (http, scgi, fastcgi, uwsgi)

–  
Roberto De Ioris

> **[unbit - Overview](https://github.com/unbit)**
>
> makers of uWSGI and many more open source projects - unbit

---

<div class="post-metadata">

**Author:** ![BiswasS\_Pinakee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7bcc69/32.png) [@BiswasS\_Pinakee](https://www.ruby-forum.com/u/BiswasS_Pinakee)\
**Post date:** [June 11, 2012, 4:02pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480/3 "2012-06-11T16:02:20Z")

</div>

Hi Roberto,

Thanks for the prompt response. That really helps.

Our major consideration for going with Nginx is performance.  
If we have another process running (a wsgi server with python  
application) and nginx working as a proxy translating HTTP requests to  
another protocol (uwsgi, http or fastcgi), won’t that be an overhead?  
I was under the impression that the Python application can be embedded  
in Nginx using Wsgi.

We would really appreciate your thoughts/suggestions on the above.

Looking forward to your response…

Thanks,  
Pinakee Biswas  
Director & CTO

Just watch it !

FE- Mail: removed\_email\_address@domain.invalid I IWeb: [http://www.vvidiacom.com](http://www.vvidiacom.com)

 Please don’t print this e-mail unless you really need to, this will  
preserve trees on planet earth.  
----------------------------Disclaimer-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
The information contained in this message (including any attachments) is  
confidential and may be privileged. If you have received it by mistake  
please notify the sender by return e-mail and permanently delete this  
message and any attachments from your system. Please note that e-mails  
are susceptible to change and malwares. VVIDIA COMMUNICATIONS PVT LTD.  
(including its group companies) shall not be liable for the improper or  
incomplete transmission of the information contained in this  
communication nor for any delay in its receipt or damage to your system.  
-------------------------------------------------------------------------------------------------------------------------Disclaimer----------------------------------------------------------------------------------------------------------

---

<div class="post-metadata">

**Author:** ![BiswasS\_Pinakee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7bcc69/32.png) [@BiswasS\_Pinakee](https://www.ruby-forum.com/u/BiswasS_Pinakee)\
**Post date:** [June 11, 2012, 8:16pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480/4 "2012-06-11T20:16:04Z")

</div>

> Hi Roberto,
> 
> Thanks for the prompt response. That really helps.
> 
> Our major consideration for going with Nginx is performance.  
> If we have another process running (a wsgi server with python application)  
> and nginx working as a proxy translating HTTP requests to another protocol  
> (uwsgi, http or fastcgi), won’t that be an overhead?

Yes, there is an overhead, but it is practically irrelevant in the big  
scheme. Your bootleneck will hardly be the webserver or the application  
server. Running custom/non-deterministic apps directly in the webserver  
is  
a really old-style approach and afaik, only the php world still pushes  
this kind of setups.

Take in account (as you came from apache), mod\_wsgi preferred setup is  
in  
daemon mode, that is a beatiful abstraction of a proxied setup.

> I was under the impression that the Python application can be embedded in  
> Nginx using Wsgi.

the only third-party-module allowing you to do so, is Manlio P.'s  
mod\_wsgi/mod\_python for nginx. It is unmaintained, and its preferred  
usage  
is in having another nginx in front of it proxying requests. Nginx is a  
non-blocking server, putting blocking code in it (as 90% of the webapps  
are), is the key to hell 🙂

If you have got experience with apache+mod\_wsgi, you can simply use  
nginx  
for serving static files and using apache+mod\_wsgi (in embedded mode) as  
your application server for python/wsgi. This is now a very common  
setup.

–  
Roberto De Ioris

> **[unbit - Overview](https://github.com/unbit)**
>
> makers of uWSGI and many more open source projects - unbit

---

<div class="post-metadata">

**Author:** ![BiswasS\_Pinakee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7bcc69/32.png) [@BiswasS\_Pinakee](https://www.ruby-forum.com/u/BiswasS_Pinakee)\
**Post date:** [June 12, 2012, 3:19pm UTC](https://www.ruby-forum.com/t/nginx-and-uwsgi/220480/5 "2012-06-12T15:19:16Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Il 11/06/2012 20:15, Roberto De Ioris ha scritto:

> […]
> 
> > I was under the impression that the Python application can be embedded in  
> > Nginx using Wsgi.
> 
> the only third-party-module allowing you to do so, is Manlio P.'s  
> mod\_wsgi/mod\_python for nginx. It is unmaintained,

Well, recently I have started to work on it again; at least now it works  
with recent Nginx versions ;-).

I have not yet pushed the latest changes to the public repository at:  
[https://bitbucket.org/mperillo/ngx\_http\_wsgi\_module](https://bitbucket.org/mperillo/ngx_http_wsgi_module).

As Roberto pointed out, ngx\_http\_wsgi\_module is not a “general” Python  
web application server; but it works rather well for “carefully” written  
applications, and memory usare is low.

> […]

Regards Manlio P.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.10 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iEYEARECAAYFAk/XQaAACgkQscQJ24LbaUR9dgCfQWI7IltdxyvI49QwT3EN+VGT  
BMUAnRIvcNZohU59rDGszLI9Toupivq6  
=tu4T  
-----END PGP SIGNATURE-----
