NGINX: upstream timed out (110: Connection timed out)

Автор: | 25/09/2014

nginx_logoИмеются Apache HTTP + NGINX.

Периодически, при добавлении поста в блог, NGINX возвращает 504 ошибку, а в лог пишет:

2014/09/25 14:14:30 [error] 3087#0: *15565 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 37.***.***.56, server: rtfm.co.ua, request: “POST /wp-admin/post.php HTTP/1.1”, upstream: “http://127.0.0.1:8080/wp-admin/post.php”, host: “rtfm.co.ua”, referrer: “http://rtfm.co.ua/wp-admin/post.php?post=5387&action=edit”

Решение – использовать директиву proxy_read_timeout.

В файл настроек хоста добавляем:

 ...
 location / {
     proxy_read_timeout 300;
     proxy_pass http://127.0.0.1:8080;
 }
 ...

Проверяем:

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Перезапускаем NGINX:

# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]

Готово.

P.S. Всё больше задумываюсь над тем, что бы перейти на NGINX + PHP-FPM. Тем более на тестовом сервере он себя показал отлично, особых проблем с миграцией быть не должно.