UPDATE: I saw questions related to the /tmp directory, and a comment mentioned moving the socket out of /home as well. It didn't fix the problem.
(Additional updates at bottom of post)
I have a ubuntu 16.04 vm on azure I'm using to host a flask application using uwsgi as the server and nginx as the reverse proxy, following this guide...
The problem is I'm getting a 502 Bad Gateway when I try to connect to the server at its ip with a web browser on port 80. When I check the logs it says that nginx cannot find the unix socket I specified in the config file.
The error is...
2016/08/29 23:23:20 [crit] 2792#2792: *120 connect() to unix:///home/me/appname/appname/appname.sock failed (2: No such file or directory) while connecting to upstream, client: ip.goes.in.here, server: here.goes.the.ip, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///home/me/appname/appname/appname.sock:", host: "the.ip.goes.here", referrer: "http://all.of.teh.ips/"
My server block looks like this...
server {
listen 80;
server_name ip.address.goes.here;
location / {
include uwsgi_params;
uwsgi_pass unix:/etc/appname.sock;
}
}
my app.ini file looks like this...
[uwsgi]
module:wsgi:app
master = true
processes = 5
socket = /etc/appname.sock
chmod-socket = 660
vacuum = true
die-on-term = true
my .service file looks like this...
[Unit]
Description=UWSGI instance to serve app
After=network.target
[Service]
User=me
Group=www-data
WorkingDirectory=/home/me/appname
ExecStart=/home/me/appnam/uwsgi --ini appname.ini
[Install]
WantedBy=multi-user.target
I also have a setup script that does the following (potentially causing problems with duplicate logs?)
sudo ufw allow 'Nginx Full'
export FLASK_APP=appname.py
export APPNAME_SETTINGS=app_settings.cfg
sudo cp service/appname.service /etc/systemd/system/appname.service
sudo cp nginxServerBlock/appname /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/appname /etc/nginx/sites-enabled
sudo nginx -t #this tests for syntax errors
sudo systemctl start appname
sudo systemctl enable appname
I changed the # of slashes after unix and before home (now etc, the dir was changed), among a bunch of other things I saw that were different in various guides.
I tried to move the socket by changing the location specified in the .ini file and in the server block, but the error is completely unchanged, so nginx seems to be looking for the socket in the same directory.
The directory nginx is searching for to find the socket is not in my configuration anywhere.
[UPDATE] I discovered that there are duplicate logs in the var/log/nginx directory, 8 copies of access.log and 8 copies of error.log. I have been running the setup script after each change (to move the files to the appropriate places after pulling the changes with git) and using daemon reload (I can't remember the exact name) as per the instructions that appear in terminal after running the setup script...could something in my script be causing the duplicates? Could it be possible that I've made some weird duplicate setup with different services by accident, each using a different pair of log files?