# Problem with nginx + uwsgi

**URL:** <https://www.ruby-forum.com/t/problem-with-nginx-uwsgi/242700>\
**Category:** NGINX\
**Created:** [July 17, 2015, 2:10pm UTC](https://www.ruby-forum.com/t/problem-with-nginx-uwsgi/242700 "2015-07-17T14:10:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [July 17, 2015, 2:10pm UTC](https://www.ruby-forum.com/t/problem-with-nginx-uwsgi/242700/1 "2015-07-17T14:10:06Z")

</div>

Hi everybody,

I’m having a problem with my nginx and uwsgi. I don’t really know  
what  
I’m doing wrong.

Here is the configuration of nginx:

server {  
listen 80;

```
    location /api/v1 {
            uwsgi_pass unix:///tmp/api.sock;
            include uwsgi_params;
    }

    location / {
            return 444;
    }

```

And this is uwsgi configuration:

[uwsgi]  
socket = /tmp/api.sock  
chdir = /var/www/api  
master = true  
plugin = python  
pp = /home/api/src  
file = uwsgi.py  
uid = www-data  
gid = www-data  
threads = 4  
workers = 4  
callable = app  
chmod-socket = 666  
post-buffering = 4096  
virtualenv = /usr/local/venvs/api  
callable = ins  
env = API\_SETTINGS\_FILE=…/…/etc/settings.py

If I execute following command everything seems to be working fine:

curl -v [http://127.0.0.1/api/v1/login](http://127.0.0.1/api/v1/login)

{  
“message”: “Method Not Allowed”,  
“status”: 405  
}

HTTP/405 it’s the expected answer since the app doesn’t allow login  
resquets with GET method, So now I’m going to try with POST.

The application expects for data such as email and password, so this  
should  
trigger a 500 in the api backend

curl [http://10.10.10.35/api/v1/login](http://10.10.10.35/api/v1/login) -X POST

uwsgi log:

[pid: 19484|app: 0|req: 5/5] 127.0.0.1 () {30 vars in 340 bytes} [Fri  
Jul  
17 12:05:00 2015] POST /api/v1/login =\> generated 0 bytes in 432 msecs  
(HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

Everything good but the answer of nginx it’s wrong:

502 Bad Gateway
# 502 Bad Gateway

* * *
nginx/1.7.1

So for any reason nginx interpret the HTTP/500 from the API as the  
gateway  
it’s no available.

Do you see what I’m doing wrong?

More info:

Nginx 1.8.0  
Ubuntu 12.04  
uWSGI 1.0.3

Thanks in advance
