NginX issues HTTP 499 error after 60 seconds despite config. (PHP and AWS)

前端 未结 5 1152
面向向阳花
面向向阳花 2020-12-02 10:42

At the end of last week I noticed a problem on one of my medium AWS instances where Nginx always returns a HTTP 499 response if a request takes more than 60 seconds. The pa

相关标签:
5条回答
  • 2020-12-02 10:49

    Actually I faced the same issue on one server and I figured out that after nginx configuration changes I didn't restart the nginx server, so with every hit of nginx url I was getting a 499 http response. After nginx restart it started working properly with http 200 responses.

    0 讨论(0)
  • 2020-12-02 10:50

    You need to find in which place problem live. I dont' know exact answer, but just let's try to find it.

    We have here 3 elements: nginx, php-fpm, php. As you told, same php settings under apache is ok. Does it's same no same setup? Did you try apache instead of nginx on same OS/host/etc.?

    If we will see, that php is not suspect, then we have two suspects: nginx & php-fpm.

    To exclude nginx: try to setup same "system" on ruby. See https://github.com/garex/puppet-module-nginx to get idea to install simplest ruby setup. Or use google (may be it will be even better).

    My main suspect here is php-fpm.

    Try to play with these settings:

    • php-fpm`s request_terminate_timeout
    • nginx`s fastcgi_ignore_client_abort
    0 讨论(0)
  • 2020-12-02 10:51

    Not sure if anyone else faced this but for me it happened after I put a / at the end my instance url.This gave 499 error and only after I removed the /, it gave me 200 and all went good.

    0 讨论(0)
  • 2020-12-02 11:06

    The cause of the problem is the Elastic Load Balancers on AWS. They, by default, timeout after 60 seconds of inactivity which is what was causing the problem.

    So it wasn't NginX, PHP-FPM or PHP but the load balancer.

    To fix this, simply go into the ELB "Description" tab, scroll to the bottom, and click the "(Edit)" link beside the value that says "Idle Timeout: 60 seconds"

    0 讨论(0)
  • 2020-12-02 11:09

    I thought I would leave my two cents. First the problem is not related with php(still could be a php related, php always surprises me :P ). Thats for sure. its mainly caused of a server proxied to itself, more specifically hostname/aliases names issue, in your case it could be the load balancer is requesting nginx and nginx is calling back the load balancer and it keeps going that way.

    I have experienced a similar issue with nginx as the load balancer and apache as the webserver/proxy

    0 讨论(0)
提交回复
热议问题