Skip to content

Commit b6332a2

Browse files
author
Bryan Latten
committed
Merge pull request #61 from bryanlatten/fpm-timeout
PHP-FPM: unified timeouts across nginx/php-fpm, TCP use instead of unix socket
2 parents c620ab9 + b3139f0 commit b6332a2

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ RUN pecl install igbinary-1.2.1 && \
4848

4949
# Prevent newrelic daemon from auto-spawning; uses newrelic run.d script to enable at runtime, when ENV variables are present
5050
# @see https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/starting-php-daemon-advanced
51-
RUN sed -i "s/;newrelic.daemon.dont_launch = 0/newrelic.daemon.dont_launch = 3/" /etc/php5/mods-available/newrelic.ini
51+
RUN sed -i "s/;newrelic.daemon.dont_launch = 0/newrelic.daemon.dont_launch = 3/" /etc/php5/mods-available/newrelic.ini && \
52+
sed -i "s/listen = \(.*\)\+/listen = 127.0.0.1:9000/" /etc/php5/fpm/pool.d/www.conf
53+
# ^^ Configure php-fpm to use TCP rather than unix socket (for stability), fastcgi_pass is also set by /etc/nginx/sites-available/default
5254

5355
# Perform cleanup, ensure unnecessary packages are removed
5456
RUN apt-get autoclean -y && \

container/root/etc/nginx/sites-available/default

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ server {
2727

2828
include /etc/nginx/fastcgi_params;
2929

30+
fastcgi_read_timeout 60;
31+
3032
# IMPORTANT: PATH_INFO is set to empty string in this configuration
3133
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
32-
fastcgi_pass unix:/var/run/php5-fpm.sock;
34+
fastcgi_pass 127.0.0.1:9000;
3335
}
3436

3537
# Protect against accessing hidden files

container/root/etc/php5/fpm/conf.d/web.user.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
memory_limit = 192M
55
max_execution_time = 60
6+
request_terminate_timeout=60
67

78
; TODO: Closes potential security hole, but doesn't allow ANY requests through
89
; @see [CAUSE] https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/

0 commit comments

Comments
 (0)