TransWikia.com

NGINX gives 502 error from browsers but not from Postman

Stack Overflow Asked by knguyen on October 13, 2020

I’ve got a Django application running on Azure App Service using NGINX.

My nginx.conf file is as follow:

user  nginx;
worker_processes 1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections 1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 128 2048k;
    fastcgi_buffer_size 2048k;
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;
    server {
        listen 8000;
        location / {
            include uwsgi_params;
            uwsgi_pass unix:///tmp/uwsgi.sock;
        }
        location /static {
            alias /app/staticfiles;
        }
    }
}

daemon off;

Everything works fine, except for one particular API where I include in the header some token (typical bearer token) and it’s returning a 502 error from Chrome (in the network tab)

However, when I try to call this from Postman, it’s returning the data correctly.

What could be possibly wrong here?

One Answer

Thanks to @Selcuk's suggestion. I've managed to fix the above error by increasing the buffer-size in iwsgi.ini file

# uwsgi.ini file

buffer-size = 32768

Answered by knguyen on October 13, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP