Search code examples
nginxuwsgi

nginx and uwsgi - protocol mismatch?


I can successfully run my django site using:

fadedbee@box:/srv/myproject $ uwsgi --http :8000 --module myproject.wsgi

I can point a browser at port 8000 and get a webpage (without the static content, as expected).

After following https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html and probably making several mistakes, nginx tries to send requests upstream, but eventually times-out.

When I use a browser against port 8000, I can see the expected HTTP protocol:

    0x0030:  1b11 0088 4745 5420 2f20 4854 5450 2f31  ....GET./.HTTP/1
    0x0040:  2e31 0d0a 486f 7374 3axx xxxx xxxx xxxx  .1..Host:xxxxxxx
    0x0050:  xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx  xxxxxxxxxxxxxxxx
    0x0060:  xx3a 3830 3030 0d0a 5573 6572 2d41 6765  x:8000..User-Age
    0x0070:  6e74 3a20 4d6f 7a69 6c6c 612f 352e 3020  nt:.Mozilla/5.0.

but the requests sent by nginx appear to use a different protocol (is there a uwsgi protocol?).

    0x0030:  220b a499 0073 0300 0c00 5155 4552 595f  "....s....QUERY_
    0x0040:  5354 5249 4e47 0000 0e00 5245 5155 4553  STRING....REQUES
    0x0050:  545f 4d45 5448 4f44 0300 4745 540c 0043  T_METHOD..GET..C
    0x0060:  4f4e 5445 4e54 5f54 5950 4500 000e 0043  ONTENT_TYPE....C
    0x0070:  4f4e 5445 4e54 5f4c 454e 4754 4800 000b  ONTENT_LENGTH...

What mistake have I made in either my nginx config, or in my uwsgi invocation, that is stopping uwsgi from replying to nginx's non-HTTP requests?


Solution

  • There are two separate protocols.

    I needed to use:

    fadedbee@box:/srv/myproject $ uwsgi --socket :8000 --module myproject.wsgi