Skip to content

Commit

Permalink
Merge pull request #61 from bryanlatten/fpm-timeout
Browse files Browse the repository at this point in the history
PHP-FPM: unified timeouts across nginx/php-fpm, TCP use instead of unix socket
  • Loading branch information
Bryan Latten committed Sep 18, 2015
2 parents c620ab9 + b3139f0 commit b6332a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ RUN pecl install igbinary-1.2.1 && \

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

# Perform cleanup, ensure unnecessary packages are removed
RUN apt-get autoclean -y && \
Expand Down
4 changes: 3 additions & 1 deletion container/root/etc/nginx/sites-available/default
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ server {

include /etc/nginx/fastcgi_params;

fastcgi_read_timeout 60;

# IMPORTANT: PATH_INFO is set to empty string in this configuration
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
}

# Protect against accessing hidden files
Expand Down
1 change: 1 addition & 0 deletions container/root/etc/php5/fpm/conf.d/web.user.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

memory_limit = 192M
max_execution_time = 60
request_terminate_timeout=60

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

0 comments on commit b6332a2

Please sign in to comment.