Forum: NGINX Time out errors using uwsgi with ngnix on debian 7 (wheezy)

E578b05cfcb9139bfb1dac63ec808f46?d=identicon&s=25 Denis Papathanasiou (Guest)
on 2014-01-09 02:16
(Received via mailing list)
I've installed nginx via apt, using the nginx stable pkg as described
here:
http://nginx.org/en/linux_packages.html#stable

It works perfectly for serving static files using the default
configuration.

Next, I installed uwsgi from source, as described here:
https://pypi.python.org/pypi/uWSGI/1.2.3

When I do the steps in the python quickstart guide --
http://uwsgi-docs.readthedocs.org/en/latest/WSGIqu... -- and
open
my browser to localhost:9090, everything works as expected.

When I change the nginx config file to use uwsgi_pass to localhost:9090
as
described here --
http://uwsgi-docs.readthedocs.org/en/latest/WSGIqu...
however, I get time out errors:

> upstream timed out (110: Connection timed out) while reading response
header from upstream

It is as though nginx is *not* passing those requests to the uwsgi
process
(which is still running).

Here is the content of server{ } inside the nginx config file:

        location / {
            include uwsgi_params;
            uwsgi_pass localhost:9090;
        }

Any ideas on what the problem might be?
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-01-09 16:03
(Received via mailing list)
Hello!

On Wed, Jan 08, 2014 at 08:15:47PM -0500, Denis Papathanasiou wrote:

> my browser to localhost:9090, everything works as expected.
> (which is still running).
>
> Here is the content of server{ } inside the nginx config file:
>
>         location / {
>             include uwsgi_params;
>             uwsgi_pass localhost:9090;
>         }
>
> Any ideas on what the problem might be?

If you are able to connect to localhost:9090 with your browser,
you are likely using native HTTP support in your uWSGI server.
The "uwsgi_pass" directive assumes uwsgi protocol though, which is
different.

You should either reconfigure uWSGI server to work via uwsgi, or
instruct nginx to talk via HTTP (i.e., use "proxy_pass" instead of
"uwsgi_pass").

--
Maxim Dounin
http://nginx.org/
E578b05cfcb9139bfb1dac63ec808f46?d=identicon&s=25 Denis Papathanasiou (Guest)
on 2014-01-09 18:08
(Received via mailing list)
Maxim,

Thank you for your reply.

On Thu, Jan 9, 2014 at 10:03 AM, Maxim Dounin <mdounin@mdounin.ru>
wrote:

> [snip]
>
> If you are able to connect to localhost:9090 with your browser,
> you are likely using native HTTP support in your uWSGI server.
>

Yes, I am starting the uwsgi process like this, using the --http flag:

uwsgi --http :9090 --wsgi-file foobar.py --master --processes 4
--threads 2


> The "uwsgi_pass" directive assumes uwsgi protocol though, which is
> different.
>
> You should either reconfigure uWSGI server to work via uwsgi, or
>

Ah, I see, I should use the --socket option instead, like this:

uwsgi --socket 127.0.0.1:9090 --wsgi-file foobar.py --master --processes
4
--threads 2

Thank you for clarifying that; it *is* in the uwsgi docs I quoted
earlier,
but it is a subtle point under the "quickstart" section, and I had
missed
it.


> instruct nginx to talk via HTTP (i.e., use "proxy_pass" instead of
> "uwsgi_pass").
>

I see: I could use "proxy_pass" and keep --http  when I start uwsgi.

Thank you, that was very helpful!
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.