PHP, Docker, Apache & EC2 - intermittent POST request failures

Viewed 69

I'm getting some very odd behaviour with my app on AWS EC2. Every now and again, when a form is submitted via POST, it'll bomb out straight away displaying the submitted form data. There are no logs in apache, PHP app logs or EC2 System logs that indicate what the issue is.

I'm using docker-compose with the following:

services:
  php:
    build: ./docker/php
    restart: always
    tty: true
    container_name: php
    networks:
      - docker.network
    ports:
      - "9000:9000"
    volumes:

  apache:
    build: ./docker/apache
    restart: always
    container_name: apache
    networks:
      - docker.network
    depends_on:
      - php
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - .:/var/www/app

PHP image:

php:7.0-fpm-alpine

ini settings:

allow_url_fopen = On
allow_url_include = Off
asp_tags = Off
display_errors = On
display_startup_errors = On
error_reporting = E_ALL
enable_dl = Off
file_uploads = On
max_execution_time = 300
max_input_time = 60
max_input_vars = 100000
memory_limit = 3000M
session.gc_maxlifetime = 1440
upload_max_filesize = 250M
post_max_size = 500M
max_file_uploads = 50
date.timezone = Europe/London

Apache image:

FROM httpd:2.4-alpine

And in the apache conf I'm proxying the requests to PHP like:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000${DOCUMENT_ROOT}/$1

I've also tried increasing the EC2 instance type to t2.medium and increasing the PHP memory_limit.

It's driving me nuts as it works most of the time, but every now and again it'll just start bombing out.

Any pointers would be appreciated.

0 Answers
Related