0

I have some websites hosted on the same server and only for 1 of them, I get a strange issue.

When I start nginx the website is reacheable and few hours after, when I try to connect again, the response time is very very slow and I get error on nginx access log file.

If I restart nginx or php-fpm (I use unix socket) then works fine..and few hours after the same problem.

here is /var/run/php/php7.2-fpm-my_website.sock conf :

user = my_website
group = my_website
listen = /var/run/php/php7.2-fpm-my_website.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

I have found some infos here Nginx 499 error codes but I'm not sure :-/

Do you have an idea why?

Nginx logs are below :

server_ip_address - - [30/Oct/2018:17:24:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:24:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:24:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:26:56 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:26:58 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:26:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:26:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:26:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" client_ip_address - - [30/Oct/2018:17:26:59 +0000] "GET /index.php HTTP/2.0" 200 7330 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" server_ip_address - - [30/Oct/2018:17:28:57 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:28:58 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:28:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" server_ip_address - - [30/Oct/2018:17:28:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-" client_ip_address - - [30/Oct/2018:17:28:59 +0000] "GET /index.php HTTP/2.0" 200 7330 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" server_ip_address - - [30/Oct/2018:17:28:59 +0000] "GET //erreur-404 HTTP/1.1" 499 0 "-" "-"

website working conf below :

server {
    listen 80;
    listen [::]:80;
    server_name website_ok.com;
    return 301 https://www.$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.website_ok.com website_ok.com;
    root /home/website_ok/www/;
    index index.html index.htm index.php;

    access_log /var/log/nginx/website_ok.access_log;
    error_log /var/log/nginx/website_ok.error_log info;

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.2-fpm-website_ok.sock;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    include /etc/nginx/conf/website_ok.conf;

    location ^~ /administrator {
            auth_basic "Authentification Requise";
            auth_basic_user_file /home/website_ok/www/administrator/.htpasswd;
    }

    include /etc/nginx/conf/joomla.conf;

    ssl_certificate /etc/letsencrypt/live/website_ok.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/website_ok.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/website_ok.com/chain.pem;

    include /etc/nginx/conf/ssl.conf;
}

website NON working conf below :

server {
    listen 80;
    listen [::]:80;
    server_name website_error.com;
    return 301 https://www.$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.website_error.com website_error.com;
    root /home/website_error/www/;
    index index.html index.htm index.php;

    access_log /var/log/nginx/website_error.access_log;
    error_log /var/log/nginx/website_error.error_log info;

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.2-fpm-website_error.sock;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    include /etc/nginx/conf/website_error.conf;

    location ^~ /administrator {
            auth_basic "Authentification Requise";
            auth_basic_user_file /home/website_error/www/administrator/.htpasswd;
    }

    include /etc/nginx/conf/joomla.conf;

    ssl_certificate /etc/letsencrypt/live/website_error.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/website_error.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/website_error.com/chain.pem;

    include /etc/nginx/conf/ssl.conf;
}

Thanks for your help L.

TooNetCreation
  • 159
  • 1
  • 3
  • 17
  • Can you please provide the failing config, along with a functioning one from your server? – Ryan Z Oct 30 '18 at 18:18
  • ok here it is website working : – TooNetCreation Oct 30 '18 at 19:44
  • conf has been added to my first post. – TooNetCreation Oct 30 '18 at 19:50
  • for info, today I started server at 11h AM and website was available today from 11h AM to 7h30 PM ... then I restart PHP-FPM with **systemctl restart php7.2-fpm** command and website is available. I think the problem is coming from PHP-FPM, but I don't know why only on 1 website and not others ? – TooNetCreation Oct 31 '18 at 19:10
  • if website works after php-fpm restart, do I need to increase memory allocated to php? – TooNetCreation Nov 01 '18 at 10:51
  • I have done a search on logs files like this **grep -r -l "GET //erreur-404 HTTP/1.1"** and there is only this website with this kind message. – TooNetCreation Nov 01 '18 at 10:54
  • post 1 edited with **/var/run/php/php7.2-fpm-my_website.sock** conf info – TooNetCreation Nov 01 '18 at 13:59
  • on nginx error log I get this : [info] 7537#7537: *46013 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while sending request to upstream, client: IP_ADDRESS, server: www.my_website.com, request: "GET //erreur-404 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm-my_website.sock:", host: "www.my_website.com" – TooNetCreation Nov 01 '18 at 14:07
  • do you think I have not enough RAM memory (8Gb currently) ? – TooNetCreation Nov 01 '18 at 21:05
  • Yes, that should be plenty. Try adding `php_value[memory_limit] = 6G` to your fpm config to ensure it will use all of the memory. – Ryan Z Nov 01 '18 at 21:09
  • OK I can try to increase **memory_limit** on php conf. but I already have this stetting for mysql **innodb_buffer_pool_size = 5120M**, is it a problem? or do I need to decrease this setting? – TooNetCreation Nov 02 '18 at 09:57

1 Answers1

0

problem solved. I have completely re-built website and works fine...seems to be a bad/wrong php script at the origin of this issue.

thanks

TooNetCreation
  • 159
  • 1
  • 3
  • 17