1 (edited by r.schnell 2017-09-27 04:06:18)

Topic: [SOLVED] os iredadmin gives 502 bad gateway - nginx

======== Required information ====
- iRedMail version (check /etc/iredmail-release):  0.9.7 MARIADB edition
- Linux/BSD distribution name and version: Raspbian GNU/Linux 8 (jessie)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? : NO (OS iredadmin)
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Running: Roundcube (with a couple of addins; haven't dug into SOGo)
Running certbot-auto with a combine certificate (reasons for this in one of the other posts)


So I have a working email system with several issues (each posted separately).  This issue is a 502 Bad Gateway error when trying to access iredadmin via https://<hostname>/iredadmin

I'm not sure when it stopped working as I don't log into it every day.

I'm at a loss...

I have tried running the upgrade script hoping to reset things. Didn't work

The following errors show up in the nginx error.log:
2017/09/20 11:13:42 [error] 1147#0: *656 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (111: Connection refused) while connecting to upstream, client: <client IP xx.xx.xx.xx>, server: _, request: "GET /iredadmin HTTP/1.1", upstream: "uwsgi://unix:/var/run/uwsgi_iredadmin.socket:", host: "<hostname>"
2017/09/20 11:47:59 [error] 1147#0: *656 upstream prematurely closed connection while reading response header from upstream, client: <client IP xx.xx.xx.xx>, server: _, request: "GET /iredadmin HTTP/1.1", upstream: "uwsgi://unix:/var/run/uwsgi_iredadmin.socket:", host: "<hostname>"

UWSGI ini:
root@<hostname>:/etc/uwsgi/apps-available# cat iredadmin.ini
[uwsgi]
plugins = python
vhost = true
#socket = /var/run/uwsgi/app/iredadmin/socket  <I added this line trying to figure this out.  It's commented because
                                                                                  it had no effect>
socket = /var/run/uwsgi_iredadmin.socket
#pidfile = /var/run/uwsgi_iredadmin.pid
chown-socket = www-data:www-data
chmod-socket = 660
uid = iredadmin
gid = iredadmin
enable-threads = true

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: [SOLVED] os iredadmin gives 502 bad gateway - nginx

Is 'uwsgi' service running?

3

Re: [SOLVED] os iredadmin gives 502 bad gateway - nginx

ZhangHuangbin wrote:

Is 'uwsgi' service running?

It is:

root@kira:/home/pi# ps aux | grep uwsgi
iredadm+  6204  0.0  0.0   9768   476 ?        S    Sep20   0:09 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --daemonize /var/log/uwsgi/app/iredadmin.log
iredadm+  6206  0.0  0.0   9768   656 ?        S    Sep20   0:00 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --daemonize /var/log/uwsgi/app/iredadmin.log
iredadm+  6208  0.0  0.0   9768   656 ?        S    Sep20   0:00 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --daemonize /var/log/uwsgi/app/iredadmin.log
root     10031  0.0  0.2   4276  1988 pts/0    S+   09:43   0:00 grep uwsgi

and

root@kira:/home/pi# systemctl status uwsgi
● uwsgi.service - LSB: Start/stop uWSGI server instance(s)
   Loaded: loaded (/etc/init.d/uwsgi)
   Active: active (running) since Wed 2017-09-20 11:47:28 CDT; 1 day 21h ago
  Process: 16577 ExecStop=/etc/init.d/uwsgi stop (code=exited, status=0/SUCCESS)
  Process: 6094 ExecStart=/etc/init.d/uwsgi start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/uwsgi.service
           ├─6204 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --dae...
           ├─6206 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --dae...
           └─6208 /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/iredadmin.ini --dae...

Sep 20 11:47:28 kira uwsgi[6094]: Starting app server(s): uwsgi -> . done.
Sep 20 11:47:28 kira systemd[1]: Started LSB: Start/stop uWSGI server instance(s).

4

Re: [SOLVED] os iredadmin gives 502 bad gateway - nginx

OK, so in mucking about in the logs, on the net, and installing fresh on a debian VM, I discovered several things:

update-alternatives --list uwsgi


gave only the following on the problem machine:

/usr/bin/uwsgi-core

it should have given:

/usr/bin/uwsgi-core
/usr/bin/uwsgi_python
/usr/bin/uwsgi_python27

So I installed uwsgi-plugin-python

apt-get install uswgi-plugin-python

It still didn't work but I was closer.
Looking at the /var/log/uwsgi/app/iredadmin.log I discovered that now it wasn't loading a module named jinja2 so I installed it:

pip install jinja2

it threw me a couple of errors:

Downloading/unpacking jinja2
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB): 340kB downloaded
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe>=0.23 in /usr/lib/python2.7/dist-packages (from jinja2)
Installing collected packages: jinja2
Compiling /tmp/pip-build-Jch81z/jinja2/jinja2/asyncfilters.py ...
  File "/tmp/pip-build-Jch81z/jinja2/jinja2/asyncfilters.py", line 7
    async def auto_to_seq(value):
            ^
SyntaxError: invalid syntax

Compiling /tmp/pip-build-Jch81z/jinja2/jinja2/asyncsupport.py ...
  File "/tmp/pip-build-Jch81z/jinja2/jinja2/asyncsupport.py", line 22
    async def concat_async(async_gen):
            ^
SyntaxError: invalid syntax

Successfully installed jinja2

but since it successfully installed I figured I try it and it worked.  I've now got to see if everything else works, but I'm going to mark this solved.