1 (edited by dcihon 2018-02-24 00:12:00)

Topic: [SOLVED] 502 Bad Gateway

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7 OPENLDAP edition
- Linux/BSD distribution name and version: Debian 9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Best I can tell after a recent set of updates I am getting this message when accessing the mail folder from Roundcube.  Going to the admin page in roundcube works fine.
Mail is working and can access it through a mail client app.

----

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

2

Re: [SOLVED] 502 Bad Gateway

You should check that fail2ban hasn't blacklisted the IP address you are connecting to Roundecube from

3

Re: [SOLVED] 502 Bad Gateway

I don't mean to be ignorant but i don't know about that package. Where do I find that information?

4

Re: [SOLVED] 502 Bad Gateway

dcihon wrote:

I don't mean to be ignorant but i don't know about that package. Where do I find that information?

https://docs.iredmail.org/file.locations.html#fail2ban
Is a good place to start

5

Re: [SOLVED] 502 Bad Gateway

Is php-fpm service running?

6

Re: [SOLVED] 502 Bad Gateway

ZhangHuangbin wrote:

Is php-fpm service running?

This is what I get:

root@mail:/etc/fail2ban# service php-fpm start
Failed to start php-fpm.service: Unit php-fpm.service not found.

7

Re: [SOLVED] 502 Bad Gateway

Lazy man big_smile

Try:

ls -l /etc/init.d/php*fpm

It's php7.0-fpm.

8

Re: [SOLVED] 502 Bad Gateway

ZhangHuangbin wrote:

Lazy man big_smile

Try:

ls -l /etc/init.d/php*fpm

It's php7.0-fpm.

So after doing this:

root@mail:/etc/fail2ban# ls -l /etc/init.d/php*fpm
-rwxr-xr-x 1 root root 4793 Jan  5 07:51 /etc/init.d/php7.0-fpm

and doing this:

root@mail:/etc/fail2ban# sudo service php7.0-fpm restart
root@mail:/etc/fail2ban# 

It made no difference.

still 502 Bad Gateway

9

Re: [SOLVED] 502 Bad Gateway

Here is some more info:

oot@mail:/etc/fail2ban# sudo service php7.0-fpm status
● php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-02-08 20:34:33 CST; 9h ago
     Docs: man:php-fpm7.0(8)
 Main PID: 16001 (php-fpm7.0)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/php7.0-fpm.service
           ├─16001 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
           ├─16002 php-fpm: pool www
           └─16003 php-fpm: pool www

Feb 08 20:34:33 mail systemd[1]: Starting The PHP 7.0 FastCGI Process Manager...
Feb 08 20:34:33 mail systemd[1]: Started The PHP 7.0 FastCGI Process Manager.
root@mail:/etc/fail2ban# 

10

Re: [SOLVED] 502 Bad Gateway

Any related error in Roundcube and Nginx log files?

FYI: https://docs.iredmail.org/file.locations.html

11

Re: [SOLVED] 502 Bad Gateway

nginx   error.log:

2018/02/10 06:17:20 [crit] 2511#2511: *26 SSL_do_handshake() failed (SSL: error:1417D18C:SSL routines:tls_process_client_hello:version too low) while SSL handshaking, client: 184.105.247.196, server: 0.0.0.0:443

nginx  access.log:

71.6.142.85 - - [10/Feb/2018:03:45:25 -0600] "GET / HTTP/1.1" 200 102 "-" "Mozilla/5.0 zgrab/0.x"
184.105.247.196 - - [10/Feb/2018:06:13:59 -0600] "GET / HTTP/1.1" 200 78 "-" "-"
107.170.236.126 - - [10/Feb/2018:06:28:31 -0600] "GET / HTTP/1.1" 200 102 "-" "Mozilla/5.0 zgrab/0.x"
139.162.106.181 - - [10/Feb/2018:08:34:54 -0600] "GET / HTTP/1.1" 200 78 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"

According to your link the roundcube logs are in the postfix log that goes into the mail.log file.
I didn't see anything in there related to roundcube.

12

Re: [SOLVED] 502 Bad Gateway

Is it possible to switch to SOGo or do I have to completely reinstall?
What web GUI does SOGo user or does it use one?

13

Re: [SOLVED] 502 Bad Gateway

Which (full) URL did you access and get the error message?

14

Re: [SOLVED] 502 Bad Gateway

https://www.mydomainname.com/mail

15

Re: [SOLVED] 502 Bad Gateway

Any error in Nginx, php-fpm, Roundcube log files when you access this url?

16

Re: [SOLVED] 502 Bad Gateway

nginx error.log shows this:

2018/02/14 12:46:03 [crit] 809#809: *78 connect() to unix:/var/run/php-fpm.socket failed (2: No such file or directory) while connecting to upstream, client: 71.14.247.18, server: _, request: "GET /mail/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.socket:", host: "www.dccathome.com"

17

Re: [SOLVED] 502 Bad Gateway

dcihon wrote:

connect() to unix:/var/run/php-fpm.socket failed (2: No such file or directory)

Is php-fpm service running?

If it's running, which socket does it create? Please check /etc/php/7.0/fpm/pool.d/www.conf.

18

Re: [SOLVED] 502 Bad Gateway

It looks like it is running:

dcihon@mail:/run$ ps aux | grep php-fpm
root       626  0.0  0.9 375992 37460 ?        Ss   06:09   0:00 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
www-data   731  0.0  0.2 375992  8752 ?        S    06:09   0:00 php-fpm: pool www
www-data   732  0.0  0.2 375992  8752 ?        S    06:09   0:00 php-fpm: pool www

What is the command to see what socket it is using?

19

Re: [SOLVED] 502 Bad Gateway

Open file /etc/php/7.0/fpm/php-fpm.conf, search 'listen' line.

20

Re: [SOLVED] 502 Bad Gateway

There is no listen line in the file:

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /run/php/php7.0-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php7.0-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless it specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is build with systemd integration, specify the interval,
; in second, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr otherwise
include=/etc/php/7.0/fpm/pool.d/*.conf

21

Re: [SOLVED] 502 Bad Gateway

My mistake. please check /etc/php/7.0/fpm/pool.d/www.conf instead.

22

Re: [SOLVED] 502 Bad Gateway

;listen = /run/php/php7.0-fpm.sock
listen = /var/run/php-fpm.sock

23

Re: [SOLVED] 502 Bad Gateway

dcihon wrote:
;listen = /run/php/php7.0-fpm.sock
listen = /var/run/php-fpm.sock

But your Nginx is configured to connect to /var/run/php-fpm.socket. You have to change either one.

24

Re: [SOLVED] 502 Bad Gateway

All I had to do was change .sock to .socket and all is working.