'uwsgi ini file configuration

I have a Python application running on a server. I am trying to configure uwsgi server in my application.

uwsgi.conf file location : /etc/init/uwsgi.conf

# file: /etc/init/uwsgi.conf
description "uWSGI starter"

start on (local-filesystems and runlevel [2345])
stop on runlevel [016]

respawn

# home - is the path to our virtualenv directory
# pythonpath - the path to our django application
# module - the wsgi handler python script

exec /home/testuser/virtual_environments/django-new/bin/uwsgi \
--uid root \
--home /home/testuser/virtual_environments/django-new \
--pythonpath /home/testuser/django \
--socket /tmp/uwsgi.sock \
--chmod-socket \
--module wsgi \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/log/uwsgi.log

and I have created this .ini file:

/etc/uwsgi/app-available/uwsgi.ini

[uwsgi]
home = /home/testuser/virtual_environments/django-new
pythonpath = /home/testuser/django
socket = /tmp/uwsgi1.sock
module = wsgi
optimize = 2 
processes = 2

nginx configuration:

/etc/nginx/site-available/default

upstream uwsgicluster {
    #server unix:/tmp/uwsgi.sock;
    server unix:///tmp/uwsgi1.sock;
}
server {
        location / {
                uwsgi_pass   uwsgicluster;
        #uwsgi_pass unix:/run/uwsgi/app/scisphere/socket;
        #proxy_pass  http://uwsgicluster;
                include /etc/nginx/uwsgi_params;
        }

        location /static {
                 root /home/testuser/django/main;
        }
        location /media {
                 root /home/testuser/django;
        }
}

I try to start the server:

sudo service uwsgi start

I am getting 502 Bad Gateway error. How to configure uwsgi.ini file in uwsgi.conf?



Solution 1:[1]

Add include uwsgi_params; below uwsgi_pass uwsgicluster;.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mr_tron