1

Topic: 502 Bad Gateway when trying to access iRedAdmin on Nginx

==== Required information ====
- iRedMail version: 0.9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Linux/BSD distribution name and version: Linux
- Related log if you're reporting an issue:
====

Firstly, I just would like to say that Nginx has a much better performance compared to Apache2. Quite fast. I was impressed.  However I cant access the iredadmin (tried to read existing forums but could not figure out whats the problem)

I am getting a :-

502 Bad Gateway
nginx

Could someone advise why is this. Do I need to stop php?

----

Get fast and professional support from iRedMail developers:

2

Re: 502 Bad Gateway when trying to access iRedAdmin on Nginx

Is uwsgi service running? iRedAdmin is a Python program running with uwsgi.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

3 (edited by superinterstellar 2015-04-24 01:49:01)

Re: 502 Bad Gateway when trying to access iRedAdmin on Nginx

ZhangHuangbin wrote:

Is uwsgi service running? iRedAdmin is a Python program running with uwsgi.

i think i found the error :-

2015/04/23 17:10:21 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:10:33 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:10:35 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:10:44 [crit] 25997#0: *1125 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:11:05 [crit] 25997#0: *1125 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:11:15 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin/dashboar$
2015/04/23 17:11:17 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin/dashboar$
2015/04/23 17:11:23 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:11:28 [crit] 25997#0: *1118 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:19:26 [emerg] 30696#0: invalid host in upstream "/var/run/uwsgi_iredadmin.socket" in /etc/nginx/conf.d/default.conf:104
2015/04/23 17:22:17 [crit] 25997#0: *1151 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 17:22:18 [crit] 25997#0: *1151 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 101.108.24.245, server: _, request: "GET /iredadmin HTTP/1.1$
2015/04/23 18:34:59 [crit] 30859#0: *76 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 171.98.205.179, server: _, request: "GET /iredadmin/dashboard $
2015/04/23 18:35:46 [crit] 30859#0: *76 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 171.98.205.179, server: _, request: "GET /iredadmin/dashboard $
2015/04/23 18:42:01 [crit] 30859#0: *79 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 171.98.205.179, server: _, request: "GET /iredadmin HTTP/1.1",$
2015/04/23 18:48:47 [crit] 30859#0: *82 connect() to unix:/var/run/uwsgi_iredadmin.socket failed (2: No such file or directory) while connecting to upstream, client: 171.98.205.179, server: _, request: "GET /iredadmin HTTP/1.1",$

i think emergency says it:-
2015/04/23 17:19:26 [emerg] 30696#0: invalid host in upstream "/var/run/uwsgi_iredadmin.socket" in /etc/nginx

**EDIT: No. Its the critical error, the emergency was my attempt to fix which made it worse. There is a socket problem.

Any idea why?



***Edit: Could someone see the config below and advise if its correct:-


    # iRedAdmin: Python scripts
    location ~ ^/iredadmin(.*) {
        rewrite ^/iredadmin(/.*)$ $1 break;
        include uwsgi_params;
        uwsgi_pass  unix:/var/run/uwsgi_iredadmin.socket;
        uwsgi_param UWSGI_CHDIR /var/www/iredadmin;
        uwsgi_param UWSGI_SCRIPT iredadmin;
        uwsgi_param SCRIPT_NAME /iredadmin;
    }
    # iRedAdmin: redirect /iredadmin to /iredadmin/
    location = /iredadmin {
        rewrite ^ /iredadmin/;
    }

4

Re: 502 Bad Gateway when trying to access iRedAdmin on Nginx

Zhang asked you, is uWSGI running? It seems like its not as its socket it missing, thus you are getting your errors.

5 (edited by superinterstellar 2015-04-24 03:15:03)

Re: 502 Bad Gateway when trying to access iRedAdmin on Nginx

oh okay.
let me try to start it.
not familiar with python.
could you advise the command / how-to? please?

thanks
kevin

EDIT : FOUND IT

service uwsgi start
Starting uWSGI for iredadmin... [uWSGI] getting INI configuration from /etc/uwsgi/iredadmin.ini
                                                           [  OK  ]

After that run :-

service nginx restart

6

Re: 502 Bad Gateway when trying to access iRedAdmin on Nginx

It looks like you just installed it, I ran into that yesterday when I wast testing.

Reboot your server, all the services don't come up immediately after install.