I’ve installed
uwsgi --version
2.0.18
python3 --version
Python 3.6.5
nginx -v
nginx version: nginx/1.17.3
on linux.
my UWSGI config works well here with CGI apps.
I’m working on setting it up with python/privacyIDEA.
PI 3.1dev2 has been pip installed,
virtualenv /opt/privacyidea
cd /opt/privacyidea
source bin/activate
pip install privacyidea==3.1dev2
...
pip show privacyidea | grep Version
Version: 3.1.dev2
I set up UWSGI systemd templates, for one service per app usage (https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html),
/etc/systemd/system/uwsgi-app@.service
[Unit]
Description=%i uWSGI app
After=syslog.target
[Service]
ExecStart=/usr/sbin/uwsgi \
--ini /etc/uwsgi/apps-available/%i.ini \
--socket /run/uwsgi/%i.sock
User=wwwrun-%i
Group=www
Restart=on-failure
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
/etc/systemd/system/uwsgi-app@.socket
[Unit]
Description=Socket for uWSGI app %i
[Socket]
ListenStream=/run/uwsgi/%i.sock
SocketUser=wwwrun-%i
SocketGroup=www
SocketMode=0660
[Install]
WantedBy=sockets.target
The uwsgi PI-config,
/etc/uwsgi/apps-available/privacyidea.ini
[uwsgi]
master = true
cheap = true
idle = 600
die-on-idle = true
processes = 8
harakiri = 3600
reload-mercy = 8
cpu-affinity = 1
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
no-orphans = true
vacuum = true
logger = file:/var/log/uwsgi/error.log
req-logger = file:/var/log/uwsgi/request.log
stats = /run/uwsgi/stats.socket
manage-script-name = true
plugins = python3,logfile
wsgi-file = /etc/privacyidea/privacyideaapp.wsgi
the referenced wsgi-file
/etc/privacyidea/privacyideaapp.wsgi
import sys
sys.stdout = sys.stderr
from privacyidea.app import create_app
application = create_app(config_name="production", config_file="/etc/privacyidea/pi.cfg")
and the PI config
/etc/privacyidea/pi.cfg
import logging
SUPERUSER_REALM = ['super']
SQLALCHEMY_DATABASE_URI = 'sqlite:////etc/privacyidea/data.sqlite'
SECRET_KEY = 't0p s3cr3t'
PI_PEPPER = "Never know..."
PI_ENCFILE = '/etc/privacyidea/enckey'
PI_AUDIT_KEY_PRIVATE = '/etc/privacyidea/private.pem'
PI_AUDIT_KEY_PUBLIC = '/etc/privacyidea/public.pem'
PI_AUDIT_SQL_TRUNCATE = True
PI_ENGINE_REGISTRY_CLASS = "shared"
PI_AUDIT_POOL_SIZE = 20
PI_LOGLEVEL = logging.DEBUG
PI_LOGFILE = "/var/log/privacyidea/privacyidea.log"
nginx config includes
upstream uwsgi_privacyidea {
server unix:/run/uwsgi/privacyidea.sock;
}
server {
listen 10.0.0.1:8888 ssl http2;
server_name pi.pgnd.loc;
...
location / {
try_files $uri @privacyidea;
}
location @privacyidea {
internal;
gzip off;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
uwsgi_pass uwsgi_privacyidea;
}
}
The app socket’s active
systemctl start uwsgi-app@privacyidea.socket
systemctl status uwsgi-app@privacyidea.socket -l
● uwsgi-app@privacyidea.socket - Socket for uWSGI app privacyidea
Loaded: loaded (/etc/systemd/system/uwsgi-app@.socket; enabled; vendor preset: disabled)
Active: active (listening) since Mon 2019-08-19 10:11:44 PDT; 103ms ago
Listen: /run/uwsgi/privacyidea.sock (Stream)
ls -al /run/uwsgi/
total 0
drwxr-xr-x 2 root root 80 Aug 19 10:11 ./
drwxr-xr-x 47 root root 1.4K Aug 19 08:52 ../
srw-rw---- 1 wwwrun-privacyidea www 0 Aug 19 10:11 privacyidea.sock=
after restarting the webserver
systemctl restart nginx
access to
https://pi.pgnd.loc:8888
returns
502 Bad Gateway
& in nginx logs
2019/08/19 10:05:18 [error] 2812#2812: *46 connect() to unix:/run/uwsgi/privacyidea.sock failed (111: Connection refused) while connecting to upstream, client: 10.0.0.9, server: pi.pgnd.loc, request: "GET / HTTP/2.0", upstream: "uwsgi://unix:/run/uwsgi/privacyidea.sock:", host: "pi.pgnd.loc:8888"
I’m unclear as to why the connetion’s refused.
So far, haven’t found the right way to debug/log the problem …
Have I missed, or misconfigured, some req’d config?
Any hints as to how/where to troubleshoot this?