Join the community today
Register Now

Nginx i get "504 Gateway Time-out"

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by giahancute2013, Jan 10, 2017.

  1. giahancute2013

    giahancute2013 New Member

    10
    1
    3
    Oct 27, 2016
    Ratings:
    +1
    Local Time:
    3:20 PM
    1.1.4
    Maria DB 10
    Please fill in any relevant information that applies to you:
    • Centmin Mod Version Installed: Centmin Mod Menu 123.09beta01
    • Nginx Version Installed: 1.11.8
    • PHP Version Installed: PHP 5.6.26 (cli) (built: Oct 10 2016 21:53:35)
    • MariaDB MySQL Version Installed:10.0.28-MariaDB
    • When was last time updated Centmin Mod code base ? : i don't remeber
    I get this note "
    Code:
    504 Gateway Time-out
    nginx

    when i curl upload too images.

    Thank you

    regards,
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    6:20 PM
    Nginx 1.13.x
    MariaDB 5.5
    What exact curl command you use to upload images via what web app/script ? These uploaded into a mysql database or filesystem hosted ?

    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    Nginx 502 or 504 Bad Gateway Errors



    Bad gateway 502 /504 timeouts are usually related to Nginx timing out waiting on PHP-FPM to respond as PHP-FPM is overloaded or overwhelmed with requests, so may need to tune PHP-FPM values. It also maybe due to PHP-FPM in turn being queued and backed up waiting on MariaDB MySQL server to respond - so also need to look at MySQL.

    You'll need to tune your PHP-FPM settings with php-fpm main pool config file at /usr/local/etc/php-fpm.conf (overview of config files) and this is left up to end user to do but here's a thread for starters to enable php status page output outlined at

    Checking PHP-FPM etc logs



    You'll also need to check into your PHP-FPM, Nginx and MariaDB logs which you can find as outlined at How to troubleshoot Centmin Mod initial install issues

    Server logs include Nginx, PHP-FPM, MariaDB MySQL error logs as well as others. You can find your Centmin Mod install/menu logs at FAQ 7 and server logs at FAQ 19 at Centmin Mod FAQ (most up to date info in FAQ so always read that first). Spoiler tag below has info too but may not be up to date.

    Some of Centmin Mod's installed software will have their own access and error logs which maybe useful for diagnosing errors or give info, notes, or warning notices.

    Note: There's no support provided by me for diagnosing such errors which may occur for various reasons including misconfiguration of installed php/mysql scripts or applications.

    In SSH2 telnet you can use tail command to view the last X number of lines in the file.

    For example for viewing last 10 lines in the file for:

    For Nginx access and error logs:
    Code:
      tail -10 /usr/local/nginx/logs/access.log
      tail -10 /usr/local/nginx/logs/error.log
    
    For specific domainname.com access and error log:
    Code:
      tail -10 /home/nginx/domains/domainname.com/log/access.log
      tail -10 /home/nginx/domains/domainname.com/log/error.log
    
    For other system error logs located at /var/log:

    list /var/log files in ascending time order so the most recently modified files are at the bottom
    Code:
      ls -lhrt /var/log
    
    Code:
    total 2.7M
    -rw------- 1 root  root    0 Aug 29 15:33 tallylog
    -rw------- 1 root  root    0 Aug 29 15:33 spooler
    drwx------ 3 root  root 4.0K Aug 29 15:35 samba
    drwxr-xr-x 2 root  root 4.0K Aug 29 15:35 mail
    -rw-r--r-- 1 root  500     0 Oct  8 18:13 dmesg.old
    -rw------- 1 root  500     0 Oct  8 18:13 boot.log
    -rw-r--r-- 1 root  500     0 Oct  8 18:14 dmesg
    drwx------ 2 root  root 4.0K Oct  8 18:14 httpd
    drwxr-xr-x 2 root  root 4.0K Oct  8 19:08 php-fpm
    -rw-rw---- 1 mysql root 2.3K Oct  9 12:38 mysqld.log
    -rw------- 1 root  root 9.2K Oct 26 10:48 yum.log
    -rw------- 1 root  utmp  94K Nov  7 22:59 btmp
    drwxr-xr-x 2 root  root 4.0K Nov  8 00:00 sa
    -rw------- 1 root  root 269K Nov  8 21:39 messages
    -rw------- 1 root  root 110K Nov  8 23:08 secure
    -rw-rw-r-- 1 root  utmp  43K Nov  8 23:08 wtmp
    -rw-r--r-- 1 root  root 144K Nov  8 23:08 lastlog
    -rw------- 1 root  root  69K Nov  8 23:08 lfd.log
    -rw------- 1 root  root 332K Nov  8 23:08 maillog
    -rw------- 1 root  500  1.6M Nov  8 23:10 cron
    
    For PHP-FPM error log:
    Code:
      tail -10 /var/log/php-fpm/www-error.log
    
    and/or
    Code:
      /var/log/php-fpm/www-php.error.log
    
    For MySQL / MariaDB error log:
    Code:
      tail -10 /var/log/mysqld.log
    
    For CSF firewall LFD log:
    Code:
      tail -10 /var/log/lfd.log
    
    For Mail log:
    Code:
      tail -10 /var/log/maillog
    
    For Cron job logs:
    Code:
      tail -10 /var/log/cron
    

    How to edit php.ini and php-fpm configuration files ?



    Centmin Mod install created command short cuts outlined here to allow you to quickly edit your /usr/local/lib/php.ini file and your /usr/local/etc/php-fpm.conf file. Full list of command shortcuts below:
    • Edit php.ini = phpedit ( /usr/local/lib/php.ini )
    • Edit my.cnf = mycnf ( /etc/my.cnf )
    • Edit php-fpm.conf = fpmconf ( /usr/local/etc/php-fpm.conf )
    • Edit nginx.conf = nginxconf ( /usr/local/nginx/conf/nginx.conf )
    • Edit (nginx) virtual.conf = vhostconf - only edits /usr/local/nginx/conf/conf.d/virtual.conf not the additional vhost domain.com.conf files added later
    • Edit (nginx) php.conf = phpinc ( /usr/local/nginx/conf/php.conf )
    • Edit (nginx) drop.conf = dropinc ( /usr/local/nginx/conf/drop.conf )
    • Edit (nginx) staticfiles.conf = statfilesinc ( /usr/local/nginx/conf/staticfiles.conf )
    • nginx stop/start/restart = ngxstop/ngxstart/ngxrestart
    • php-fpm stop/start/restart = fpmstop/fpmstart/fpmrestart
    • mysql stop/start/restart = mysqlstop/mysqlstart/mysqlrestart
    • nginx + php-fpm stop/start/restart = npstop/npstart/nprestart
    • memcached stop/start/restart =memcachedstop/memcachedstart/memcachedrestart
    • csf stop/start/restart = csfstop/csfstart/csfrestart

    Troubleshooting Tools



    However, there's many linux tools and scripts that can help you figure out what was causing the load issues and when.

    Tools and commands you will want to read up on and learn for basic system admin tasks and troubleshooting.
    Notes:
    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)
     
  3. giahancute2013

    giahancute2013 New Member

    10
    1
    3
    Oct 27, 2016
    Ratings:
    +1
    Local Time:
    3:20 PM
    1.1.4
    Maria DB 10
    Code:
    [root@li866-82 centminmod]# tail -10 /usr/local/nginx/logs/error.log
    2017/01/10 11:15:55 [alert] 29504#0: *4027 open socket #3 left in connection 32
    2017/01/10 11:15:55 [alert] 29504#0: aborting
    2017/01/10 11:15:55 [emerg] 539#0: dlopen() "/usr/local/nginx/modules/ngx_http_image_filter_module.so" failed (/usr/local/nginx/modules/ngx_http_image_filter_module.so: cannot open shared object file: No such file or directory) in /usr/local/nginx/conf/dynamic-modules.conf:1
    2017/01/10 11:16:02 [emerg] 543#0: dlopen() "/usr/local/nginx/modules/ngx_http_image_filter_module.so" failed (/usr/local/nginx/modules/ngx_http_image_filter_module.so: cannot open shared object file: No such file or directory) in /usr/local/nginx/conf/dynamic-modules.conf:1
    2017/01/10 11:28:05 [emerg] 14609#0: dlopen() "/usr/local/nginx/modules/ngx_http_image_filter_module.so" failed (/usr/local/nginx/modules/ngx_http_image_filter_module.so: cannot open shared object file: No such file or directory) in /usr/local/nginx/conf/dynamic-modules.conf:1
    [root@li866-82 centminmod]# 

    Code:
    [root@li866-82 centminmod]# tail -10 /home/nginx/domains/domain.com/log/error.log
    2017/01/10 11:29:01 [error] 14706#14706: *12 open() "/home/nginx/domains/domain.com/public/t/images/checkmark.png" failed (2: No such file or directory), client: 113.170.234.216, server: domain.com, request: "GET /t/images/checkmark.png HTTP/2.0", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 11:34:02 [error] 14706#14706: *12 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 113.170.234.216, server: domain.com, request: "POST /t/ HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:06:57 [error] 15696#15696: *30 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 113.170.234.216, server: domain.com, request: "POST /t/ HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:12:09 [error] 15696#15696: *63 open() "/home/nginx/domains/domain.com/public/t/images/checkmark.png" failed (2: No such file or directory), client: 113.170.234.216, server: domain.com, request: "GET /t/images/checkmark.png HTTP/2.0", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:16:46 [error] 15696#15696: *63 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 113.170.234.216, server: domain.com, request: "POST /t/ HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:30:31 [error] 15696#15696: *556 open() "/home/nginx/domains/domain.com/public/t/images/checkmark.png" failed (2: No such file or directory), client: 113.170.234.216, server: domain.com, request: "GET /t/images/checkmark.png HTTP/2.0", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:32:06 [error] 15696#15696: *556 open() "/home/nginx/domains/domain.com/public/t/images/checkmark.png" failed (2: No such file or directory), client: 113.170.234.216, server: domain.com, request: "GET /t/images/checkmark.png HTTP/2.0", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 12:38:30 [error] 15696#15696: *686 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 113.170.234.216, server: domain.com, request: "POST /t/ HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 14:54:52 [error] 15696#15696: *3076 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 113.170.234.216, server: domain.com, request: "POST /t/ HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com", referrer: "https://domain.com/t/"
    2017/01/10 22:44:40 [error] 15696#15696: *6425 directory index of "/home/nginx/domains/domain.com/public/" is forbidden, client: 198.199.88.169, server: domain.com, request: "GET / HTTP/1.1", host: "domain.com"
    Code:
    [root@li866-82 php-fpm]# tail -10 www-error.log
    [10-Jan-2017 12:20:21] WARNING: [pool www] child 16001, script '/home/nginx/domains/domain.com/public/t/index.php' (request: "POST /t/index.php") execution timed out (394.949080 sec), terminating
    [10-Jan-2017 12:20:21] WARNING: [pool www] child 16001 exited on signal 15 (SIGTERM) after 394.953550 seconds from start
    [10-Jan-2017 12:42:01] WARNING: [pool www] child 16497, script '/home/nginx/domains/domain.com/public/t/index.php' (request: "POST /t/index.php") execution timed out (390.576814 sec), terminating
    [10-Jan-2017 12:42:01] WARNING: [pool www] child 16497 exited on signal 15 (SIGTERM) after 390.580685 seconds from start
    [10-Jan-2017 13:31:03] WARNING: [pool www] server reached max_children setting (4), consider raising it
    [10-Jan-2017 18:07:20] WARNING: [pool www] server reached max_children setting (4), consider raising it
    [10-Jan-2017 18:32:06] WARNING: [pool www] server reached max_children setting (4), consider raising it
    [10-Jan-2017 18:35:00] WARNING: [pool www] server reached max_children setting (4), consider raising it
    [10-Jan-2017 18:36:00] WARNING: [pool www] server reached max_children setting (4), consider raising it
    [10-Jan-2017 23:33:39] WARNING: [pool www] server reached max_children setting (4), consider raising it
    Code:
    tail -10 www-php.error.log
    [10-Jan-2017 18:45:54 UTC] PHP Warning:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in /home/nginx/domains/domain.com/public/image/p.php on line 16
    [10-Jan-2017 18:45:54 UTC] PHP Warning:  imagecreatefromjpeg(): 'temp/7dc76c6c6f721238f02b8aeef60598e8.jpg' is not a valid JPEG file in /home/nginx/domains/domain.com/public/image/p.php on line 16
    [10-Jan-2017 18:45:54 UTC] PHP Warning:  imagejpeg() expects parameter 1 to be resource, boolean given in /home/nginx/domains/domain.com/public/image/p.php on line 17
    [10-Jan-2017 18:45:54 UTC] PHP Warning:  imagedestroy() expects parameter 1 to be resource, boolean given in /home/nginx/domains/domain.com/public/image/p.php on line 18
    [10-Jan-2017 18:45:55 UTC] PHP Warning:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in /home/nginx/domains/domain.com/public/image/p.php on line 16
    [10-Jan-2017 18:45:55 UTC] PHP Warning:  imagecreatefromjpeg(): 'temp/7dc76c6c6f721238f02b8aeef60598e8.jpg' is not a valid JPEG file in /home/nginx/domains/domain.com/public/image/p.php on line 16
    [10-Jan-2017 18:45:55 UTC] PHP Warning:  imagejpeg() expects parameter 1 to be resource, boolean given in /home/nginx/domains/domain.com/public/image/p.php on line 17
    [10-Jan-2017 18:45:55 UTC] PHP Warning:  imagedestroy() expects parameter 1 to be resource, boolean given in /home/nginx/domains/domain.com/public/image/p.php on line 18
    [10-Jan-2017 20:11:35 UTC] PHP Notice:  getimagesize(): Read error! in /home/nginx/domains/domain.com/public/image/p.php on line 23
    [10-Jan-2017 20:11:35 UTC] PHP Warning:  unlink(temp/temp/d6b389627ee7a5da37795f414d2ae43b.jpg): No such file or directory in /home/nginx/domains/domain.com/public/image/p.php on line 26
    Code:
    tail -10 localhost.error.log
    2017/01/10 11:49:55 [error] 14706#14706: *67 open() "/usr/local/nginx/html/manager/html" failed (2: No such file or directory), client: 201.183.237.8, server: li866-82.members.linode.com, request: "GET /manager/html HTTP/1.1", host: "139.162.24.82"
    2017/01/10 12:42:49 [error] 15696#15696: *774 open() "/usr/local/nginx/html/manager/html" failed (2: No such file or directory), client: 201.183.237.8, server: li866-82.members.linode.com, request: "GET /manager/html HTTP/1.1", host: "139.162.24.82"
    2017/01/10 21:37:45 [error] 15696#15696: *6298 open() "/usr/local/nginx/html/phpmyadmin" failed (2: No such file or directory), client: 222.186.58.12, server: li866-82.members.linode.com, request: "GET /phpmyadmin HTTP/1.1", host: "139.162.24.82", referrer: "http://139.162.24.82/phpmyadmin"
    2017/01/11 00:21:29 [error] 15696#15696: *6662 open() "/usr/local/nginx/html/muieblackcat" failed (2: No such file or directory), client: 46.165.221.74, server: li866-82.members.linode.com, request: "GET /muieblackcat HTTP/1.1", host: "139.162.24.82"
    Code:
    [root@li866-82 log]# tail -10 mysqld.log
    2017-01-05 11:05:35 7fe6ef3ff700  InnoDB: Rollback of non-prepared transactions completed
    170105 11:05:35 [Note] InnoDB: zip_dict and zip_dict_cols system tables created.
    170105 11:05:35 [Note] InnoDB: Waiting for purge to start
    170105 11:05:35 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.32-79.0 started; log sequence number 12215199
    2017-01-05 11:05:35 7fe6ebbf8700 InnoDB: Loading buffer pool(s) from .//ib_buffer_pool
    2017-01-05 11:05:35 7fe6ebbf8700 InnoDB: Buffer pool(s) load completed at 170105 11:05:35
    170105 11:05:35 [Note] Plugin 'FEEDBACK' is disabled.
    170105 11:05:35 [Note] Server socket created on IP: '::'.
    170105 11:05:35 [Note] /usr/sbin/mysqld: ready for connections.
    Version: '10.0.28-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
    Code:
    [root@li866-82 log]# tail -10 /var/log/lfd.log
    Jan 11 00:00:02 li866-82 lfd[23798]: Exploit Tracking...
    Jan 11 00:00:02 li866-82 lfd[23798]: Directory Watching...
    Jan 11 00:00:02 li866-82 lfd[23798]: Temp to Perm Block Tracking...
    Jan 11 00:00:02 li866-82 lfd[23798]: Account Tracking...
    Jan 11 00:00:02 li866-82 lfd[23798]: SSH Tracking...
    Jan 11 00:00:02 li866-82 lfd[23798]: SU Tracking...
    Jan 11 00:00:02 li866-82 lfd[23798]: Watching /var/log/messages...
    Jan 11 00:00:02 li866-82 lfd[23798]: Watching /var/log/secure...
    Jan 11 00:00:02 li866-82 lfd[23798]: Watching /var/log/customlog...
    Jan 11 00:00:02 li866-82 lfd[23798]: Watching /var/log/httpd/error_log...
    Code:
    [root@li866-82 log]# tail -10 /var/log/cron
    Jan 11 00:01:01 li866-82 CROND[23812]: (root) CMD (run-parts /etc/cron.hourly)
    Jan 11 00:01:01 li866-82 run-parts(/etc/cron.hourly)[23812]: starting 0anacron
    Jan 11 00:01:01 li866-82 anacron[23821]: Anacron started on 2017-01-11
    Jan 11 00:01:01 li866-82 anacron[23821]: Normal exit (0 jobs run)
    Jan 11 00:01:01 li866-82 run-parts(/etc/cron.hourly)[23823]: finished 0anacron
    Jan 11 00:10:01 li866-82 CROND[23872]: (root) CMD (/home/base/backup_rotation.sh)
    Jan 11 00:10:01 li866-82 CROND[23873]: (root) CMD (/usr/lib64/sa/sa1 1 1)
    Jan 11 00:11:01 li866-82 CROND[23910]: (root) CMD (/usr/local/src/centminmod/tools/autoprotect.sh 2>/dev/null)
    Jan 11 00:20:01 li866-82 CROND[24034]: (root) CMD (/usr/lib64/sa/sa1 1 1)
    Jan 11 00:30:01 li866-82 CROND[24206]: (root) CMD (/usr/lib64/sa/sa1 1 1)
    that's all my log.
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    6:20 PM
    Nginx 1.13.x
    MariaDB 5.5
    you use imagemagick php features ? looks like someone tried to upload an invalid format image.. double check and run centmin.sh menu option 15 to ensure latest imagemagick system package + latest imagick php extension is used

    if those aren't valid directories then nothing to worry about just folks probing and or scanning for common directories for your main hostname vhost site

    rest looks good so just need to tweak and tune your php-fpm settings through trial and error

    one done, let me know and i'll remove some of these posts contents as they contain your server hostname and ip :)
     
  5. giahancute2013

    giahancute2013 New Member

    10
    1
    3
    Oct 27, 2016
    Ratings:
    +1
    Local Time:
    3:20 PM
    1.1.4
    Maria DB 10
    I get this note "
    Code:
    504 Gateway Time-out
    nginx
    when i curl upload too images.

    i fixed "imagemagick" but i think it's not a problem 504 gateway time-out.


    and how can i find " request_terminate_timeout " ? i want to set value to 600s
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    6:20 PM
    Nginx 1.13.x
    MariaDB 5.5
    That value is disabled by default PHP: Configuration - Manual.
    That is in /usr/local/etc/php-fpm.conf , you can type command shortcut = fpmconf to trigger nano editor opening /usr/local/etc/php-fpm.conf. For command shortcuts see FAQ item 16.
     
  7. giahancute2013

    giahancute2013 New Member

    10
    1
    3
    Oct 27, 2016
    Ratings:
    +1
    Local Time:
    3:20 PM
    1.1.4
    Maria DB 10
    So i cannot fix
    Code:
    504 Gateway Time-out
    nginx
    when i curl upload too more images. (30+ images )

    :((
     
    Last edited: Jan 11, 2017
  8. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    6:20 PM
    Nginx 1.13.x
    MariaDB 5.5
    You'll need to tweak and tune your PHP-FPM settings with php-fpm main pool config file at /usr/local/etc/php-fpm.conf (overview of config files) and this is left up to end user to do but here's a thread for starters to enable php status page output outlined at
    basically your uploads are large and/or slow so queue and hog up php-fpm childrens available for other php requests
     
  9. giahancute2013

    giahancute2013 New Member

    10
    1
    3
    Oct 27, 2016
    Ratings:
    +1
    Local Time:
    3:20 PM
    1.1.4
    Maria DB 10
    i try to config my php-fpm but i always get that error :(
    This is my php-fpm

    Code:
    ; Log level
    ; Possible Values: alert, error, warning, notice, debug
    ; Default Value: notice
    log_level = warning
    pid = /var/run/php-fpm/php-fpm.pid
    error_log = /var/log/php-fpm/www-error.log
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m
    process_control_timeout = 10s
    include=/usr/local/nginx/conf/phpfpmd/*.conf
    
    [www]
    user = nginx
    group = nginx
    
    listen = 127.0.0.1:9000
    listen.allowed_clients = 127.0.0.1
    listen.backlog = -1
    
    ;listen = /tmp/php5-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0666
    
    pm = ondemand
    pm.max_children = 35
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 3
    pm.max_requests = 4000
    ;pm.max_children = 4
    ;pm.max_requests = 500
    
    ; PHP 5.3.9 setting
    ; The number of seconds after which an idle process will be killed.
    ; Note: Used only when pm is set to 'ondemand'
    ; Default Value: 10s
    pm.process_idle_timeout = 10s;
    
    rlimit_files = 65536
    rlimit_core = 0
    
    ; The timeout for serving a single request after which the worker process will
    ; be killed. This option should be used when the 'max_execution_time' ini option
    ; does not stop script execution for some reason. A value of '0' means 'off'.
    ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
    ; Default Value: 0
    request_terminate_timeout = 5m
    request_slowlog_timeout = 5m
    
    slowlog = /var/log/php-fpm/www-slow.log
    
    pm.status_path = /phpstatus
    ping.path = /phpping
    ping.response = pong
    
    ; Limits the extensions of the main script FPM will allow to parse. This can
    ; prevent configuration mistakes on the web server side. You should only limit
    ; FPM to .php extensions to prevent malicious users to use other extensions to
    ; exectute php code.
    ; Note: set an empty value to allow all extensions.
    ; Default Value: .php
    security.limit_extensions = .php .php3 .php4 .php5
    
    ; catch_workers_output = yes
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    php_admin_value[disable_functions] = shell_exec
    
     
  10. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    6:20 PM
    Nginx 1.13.x
    MariaDB 5.5
    you stil get max children reached errors ?

    5 minutes is too long for some of those time outs basically because that allows slow processing requests like large uploads to hog up the php max children probably

    other timeouts are in /usr/local/nginx/conf/php.conf (command shortcut = phpinc) but there's sufficiently set for most applications though you may want to try tuning those too and restart php-fpm and nginx services afterwards
    Code (Text):
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 512k;
    fastcgi_buffers 512 16k;
    fastcgi_busy_buffers_size 1m;
    fastcgi_temp_file_write_size 4m;
    fastcgi_max_temp_file_size 4m;
    


    • how large are the images ?
    • what is your ISP connection speed you are uploading via ?
    • what is your server's network connection speed ? some are capped at 50mbps, 100mbps or 1000mbps
    • how many images can you upload before you get the 504 error (making sure to restart nginx + php-fpm between number of images upload test) ?
    • also contents of /var/log/php-fpm/www-slow.log ? wrap in CODE bbcode tags
    edit: also may want to update to PHP 5.6.29 latest as 5.6.26 is a bit dated and could of had bug fixes since

     
    Last edited: Jan 12, 2017