Forum: NGINX Nginx and Python

Posted by Silvio Siefke (Guest)
on 2013-01-21 18:55
(Received via mailing list)
Hello,


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

http://www.collabspot.com/2012/08/14/setting-up-ng...

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:

<vhost>
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;
  }
}

<uwsgi>
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

<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
Posted by Jonathan Matthews (Guest)
on 2013-01-21 20:16
(Received via mailing list)
On 21 January 2013 17:54, Silvio Siefke <siefke_listen@web.de> 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 Matthews // Oxford, London, UK
http://www.jpluscplusm.com/contact.html
Posted by kirpit (Guest)
on 2013-01-21 20:27
(Received via mailing list)
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:
http://wiki.nginx.org/Configuration#Python_via_uWSGI

go dig nginx and uwsgi config files from my multi-app scenario:
 https://github.com/kirpit/webstack

cheers.
Posted by Silvio Siefke (Guest)
on 2013-01-21 23:28
(Received via mailing list)
Hello,

On Mon, 21 Jan 2013 19:15:21 +0000
Jonathan Matthews <contact@jpluscplusm.com> 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, 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
Posted by Scott Ribe (Guest)
on 2013-01-21 23:30
(Received via mailing list)
On Jan 21, 2013, at 3:26 PM, Silvio Siefke wrote:

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

Well, there's your problem...

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.