1 (edited by strzelec71 2019-01-22 23:06:31)

Topic: Problem with php7.2-fpm.sock / 502 Bad Gateway

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? installer
- Linux/BSD distribution name and version: Ubuntu 18.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MariaDB
- 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.
====

Hello,
I am a new iRedMail user. It looks like it works very well.
But...
I want to install mailwizz on the same server. I could not do it because I had a 502 error in my browser.
There was no php7.2-fpm.sock in /var/run/php

I modified /etc/nginx/nginx.conf and /etc/php/7.2/fpm/pool.d/www.conf

For now I have problem with both scripts - can't open mail.mydomain.com/mail/ and sender.mydomain.com/install/index.php - 502 Bad Gateway

EDIT: After modification sender.mydomain.com.conf file (below new version) I have acces to sender.mydomain.com/install/index.php, but still do not have access to mail.mydomain.com/mail/
In error log is only first line from code below.

Nginx error log:

2019/01/22 12:48:01 [error] 5763#5763: *65 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xxx.xx, server: _, request: "GET /mail/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9999", host: "mail.mydomain.com"
2019/01/22 12:48:04 [error] 5763#5763: *67 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xxx.xx, server: sender.mydomain.com, request: "GET /install/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sender.mydomain.com"

/etc/nginx/nginx.conf:

user www-data;
worker_processes 2;
worker_rlimit_nofile 15000;
pid /var/run/nginx.pid;

events {
    worker_connections 2048;
    multi_accept on;
    use epoll;
}

http {
    include /etc/nginx/conf-enabled/*.conf;
    include /etc/nginx/sites-enabled/*.conf;

/etc/php/7.2/fpm/pool.d/www.conf:

[inet]
user = www-data
group = www-data

listen = 127.0.0.1:9999
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
listen.allowed_clients = 127.0.0.1
listen = /var/run/php/php7.2-fpm.sock

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 5

pm.status_path = /status
ping.path = /ping

request_terminate_timeout = 10s
request_slowlog_timeout = 10s

;
; Log files
;
access.log = /var/log/php-fpm/php-fpm.log
slowlog = /var/log/php-fpm/slow.log

/etc/nginx/sites-available/sender.mydomain.com.conf (linked to sites-enabled):

server {
        listen 80;
        listen [::]:80;
        root /var/www/sender;
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name sender.mydomain.com;

         # Redirect all insecure http:// requests to https://
        return 301 https://$host$request_uri;
}

server {
        listen 443;
        listen [::]:443;

        root /var/www/sender;
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name sender.mydomain.com;

        #location / {
        #try_files $uri $uri/ =404;
        #}

 location / {
         if (!-e $request_filename){
         rewrite ^(/)?api/.*$ /api/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(/)?customer/.*$ /customer/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(/)?backend/.*$ /backend/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(.*)$ /index.php;
         }
        # index  index.html index.htm index.php;
     }

        #error_page  404              /404.html;

     # redirect server error pages to the static page /50x.html
     #
     error_page   500 502 503 504  /50x.html;

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     #
     location ~ \.php$ {

         include /etc/nginx/snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

         fastcgi_split_path_info  ^(.+\.php)(.*)$;

         fastcgi_param  PATH_INFO        $fastcgi_path_info;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include fastcgi_params;

        # fastcgi_pass   127.0.0.1:9000;
        # fastcgi_index  index.php;

         fastcgi_read_timeout 600s;
         fastcgi_send_timeout 600s;
     }

     # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     location ~ /\.ht {
         deny  all;
     }
}

I did not change default configuration files.
EDIT: Myślę, że problem jest w domyślnych plikach konfiguracyjnych.

Any help?

----

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

2

Re: Problem with php7.2-fpm.sock / 502 Bad Gateway

Hi

Change your settings as

pm = dynamic
pm.max_children = 100
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 100

request_terminate_timeout = 30s

Also I remember did a change in php.ini file.

php.ini
max_execution_time = 30

No errors occurred after these changes. But I am still watching server.

Have a nice day.

Hasan Alp İNAN

3

Re: Problem with php7.2-fpm.sock / 502 Bad Gateway

Thanks, but these settings are unlikely to cause an error 502. But of course I tested. No effect.
I think that the error may be in this part of /etc/php/7.2/fpm/pool.d/www.conf:

listen = 127.0.0.1:9999
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
listen.allowed_clients = 127.0.0.1
listen = /var/run/php/php7.2-fpm.sock

Two times

listen = 


In the nginx error log is:

2019/01/23 09:58:47 [error] 22179#22179: *3 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xxx.xx, server: _, request: "GET /mail/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9999", host: "mail.mydomain.com"
upstream: "fastcgi://127.0.0.1:9999"

Any suggestions?

4

Re: Problem with php7.2-fpm.sock / 502 Bad Gateway

Hi

In my server config only one listen= . Also owner and group www. Here is my server www.conf. OS: FreeBSD 11.2

[inet]
user = www
group = www

listen = 127.0.0.1:9999
listen.owner = www
listen.group = www
listen.mode = 0660
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 100
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 100

pm.status_path = /status
ping.path = /ping

request_terminate_timeout = 30s
request_slowlog_timeout = 10s

;
; Log files
;
access.log = /var/log/php-fpm/php-fpm.log
slowlog = /var/log/php-fpm/slow.log

5

Re: Problem with php7.2-fpm.sock / 502 Bad Gateway

hainan, thanks for your suggestions, but this was problem with nginx/php-fpm configuration.
The entries in www.conf file were not valid and did not match entries in the php-fpm.conf file.
I tried a few times, but finally it worked. And I hope it will remain so.