Skip to content

Connection timeout på Nginx med Php5-fpm

Hvis du ser noget lignende

upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.0.0.10, server: _, request:

i Nginx error log. Skydes det at Php tager for lang tid om at svare.

Som standard er timeout på 60 sekunder og normalt burde man nok heller ikke have nogle scripts der tager længere tid. Hvis det ikke er en fejl at det tager så lang tid kan du vælge at sætte tiden op.

Det gøre ved at sætte proxy_read_timeout inde i location delen i Nginx site konfiguration.
Nednfor ses min typiske konfiguration hvor jeg har tilføjet en proxy_read_timeout 300 som eksempel.

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/;
        index index.php index.html index.htm;

        server_name _;

        location / {
                proxy_read_timeout 300;
                # rewrite url
                try_files $uri $uri/ /index.php?$args ;
        }

        error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

 

This Post Has 0 Comments

Skriv et svar

Back To Top