# Nginx and Python

**URL:** <https://www.ruby-forum.com/t/nginx-and-python/225650>\
**Category:** NGINX\
**Created:** [January 21, 2013, 6:55pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650 "2013-01-21T18:55:58Z")\
**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:** [January 21, 2013, 6:55pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650/1 "2013-01-21T18:55:58Z")

</div>

Hello,

i try for a tutorial Python / Django and Nginx unite.

[http://www.collabspot.com/2012/08/14/setting-up-nginx-uwsgi-python-ubuntu-12-04/](http://www.collabspot.com/2012/08/14/setting-up-nginx-uwsgi-python-ubuntu-12-04/)

That sounds like a multi-hosting, and was not particularly difficult.  
But  
something is wrong with the system.

When i want on the website, i become a 502 Bad Gateway. The Socket  
would not be create.

Configuration:

gentoo-mobile conf # cat nginx.conf server { listen 80; server\_name python.silviosiefke.de; root /var/www/python.silviosiefke.de/src/silviosiefke; access\_log /var/www/python.silviosiefke.de/logs/access.log; error\_log /var/www/python.silviosiefke.de/logs/error.log;

location / {  
include /etc/nginx/configuration/uwsgi\_params;  
uwsgi\_pass unix:///tmp/python.silviosiefke.de.sock;  
}  
}

gentoo-mobile conf # cat uwsgi.ini [uwsgi] # variables projectname = silviosiefke projectdomain = python.silviosiefke.de base = /var/www/python.silviosiefke.de # config protocol = uwsgi venv = /var/www/python.silviosiefke.de/venv pythonpath = /var/www/python.silviosiefke.de/src/silviosiefke module = %(projectname).wsgi socket = /tmp/python.silviosiefke.de.sock logto = /var/www/python.silviosiefke.de/logs/uwsgi.log 2013/01/21 18:50:17 [crit] 4539#0: \*1 connect() to unix:///tmp/python.silviosiefke.de.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.2.20, server: python.silviosiefke.de, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/python.silviosiefke.de.sock:", : "python.silviosiefke.de"

The socket is not present in /tmp. Whereis the mistake?

Is there no way to make the Vhost configuration so that it does not  
matter what the user is in? PHP, Perl or Python?

Really Thank you for help. Greetings  
Silvio

---

<div class="post-metadata">

**Author:** ![silviosilva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@silviosilva](https://www.ruby-forum.com/u/silviosilva)\
**Post date:** [January 21, 2013, 8:16pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650/2 "2013-01-21T20:16:03Z")

</div>

On 21 January 2013 17:54, Silvio S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\>

> The socket is not present in /tmp. Whereis the mistake?

It looks like uWSGI hasn’t created it. Perhaps you didn’t run it in a  
way such that it had permission to do so.  
I’m afraid I can’t help you troubleshoot that program and, just FYI,  
this isn’t the mailing list on which to do that.

> Is there no way to make the Vhost configuration so that it does not  
> matter what the user is in? PHP, Perl or Python?

If your code/container can listen on a socket, and you know what  
protocol it speaks, and can deterministically configure nginx to use  
that protocol, then there’s no reason why you can’t abstract the nginx  
config away from having per-app knowledge. I suggest that it’s  
probably more bother than it’s worth, unless you have very specific  
mass-hosting or NoOps requirements, however.

## Jonathan

Jonathan M. // Oxford, London, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**

---

<div class="post-metadata">

**Author:** ![silviosilva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@silviosilva](https://www.ruby-forum.com/u/silviosilva)\
**Post date:** [January 21, 2013, 8:27pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650/3 "2013-01-21T20:27:09Z")

</div>

yeah, your uwsgi instance is not working or somehow socket is simply not  
there.

and for the application-agnostic configuration; you basically have to  
pass  
some parameters to your upstreams about the current request and then  
handle  
these params from them. see there is a similar example on nginx  
documentation:

> **[Getting Started | NGINX](https://www.nginx.com/resources/wiki/start/)**
>
> Useful tools, examples, and other learning resources for getting started with NGINX.

go dig nginx and uwsgi config files from my multi-app scenario:  
[GitHub - kirpit/webstack: staging / production \*nix web server configuration package](https://github.com/kirpit/webstack)

cheers.

---

<div class="post-metadata">

**Author:** ![silviosilva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@silviosilva](https://www.ruby-forum.com/u/silviosilva)\
**Post date:** [January 21, 2013, 11:28pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650/4 "2013-01-21T23:28:20Z")

</div>

Hello,

On Mon, 21 Jan 2013 19:15:21 +0000  
Jonathan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It looks like uWSGI hasn’t created it. Perhaps you didn’t run it in a  
> way such that it had permission to do so.  
> I’m afraid I can’t help you troubleshoot that program and, just FYI,  
> this isn’t the mailing list on which to do that.

No it will be created. There was something wrong in my reading. 🙂  
When i not start uwsgi then the socket can not create.

Now i become the log:  
2013/01/21 23:06:52 [crit] 7472#0: \*5 connect() to  
unix:///tmp/python.silviosiefke.de.sock failed (13: Permission denied)  
while connecting to upstream, client: 192.168.2.20,  
server: [python.silviosiefke.de](http://python.silviosiefke.de), request: “GET /favicon.ico HTTP/1.1”,  
upstream: “uwsgi://unix:///tmp/python.silviosiefke.de.sock:”,  
host: “python.silviosiefke.de:92”

> If your code/container can listen on a socket, and you know what  
> protocol it speaks, and can deterministically configure nginx to use  
> that protocol, then there’s no reason why you can’t abstract the nginx  
> config away from having per-app knowledge. I suggest that it’s  
> probably more bother than it’s worth, unless you have very specific  
> mass-hosting or NoOps requirements, however.

Mass hoster I’m not, I will not be. There are customers whose computers  
and networks I care. Years ago, I once asked a hosting and now I host a  
few more. But before I can offer my customers, I need to test self and  
understand. I would not start with Apache again, Nginx has been a good  
companion and should stay.

I try the way from nginx Wiki, maybe run it. When can i switch the  
clients  
to extra server for python hosting.

Regards & Thank you  
Silvio

---

<div class="post-metadata">

**Author:** ![silviosilva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@silviosilva](https://www.ruby-forum.com/u/silviosilva)\
**Post date:** [January 21, 2013, 11:30pm UTC](https://www.ruby-forum.com/t/nginx-and-python/225650/5 "2013-01-21T23:30:40Z")

</div>

On Jan 21, 2013, at 3:26 PM, Silvio S. wrote:

> unix:///tmp/python.silviosiefke.de.sock failed (13: Permission denied)

Well, there’s your problem…

–  
Scott R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> **[Elevated Software Development, Inc.](http://www.elevated-dev.com/)**

(303) 722-0567 voice
