nginx – php-fpm “Cannot modify header information” error

I have two docker containers linked by a docker network. One is running nginxinc/nginx-unprivileged and the other is running php:fpm. I have linked them together so that the php:fpm container handles running the php, however when the php tried to update the page I get a header error (shown below).

I saw a suggestion to check the output_buffering parameter inside php.ini, however mine is already set to 4096.

Does anyone have any idea where I may be missing something here?

This is the error I receive in the web browser:

Array ( (fullname) => dsd (suggestion) => da )
Warning: Cannot modify header information - headers already sent by (output started at /usr/share/nginx/html/action.php:17) in /usr/share/nginx/html/action.php on line 33

Here are my dockerfiles:

nginx:

# Rootless Webserver Dockerfile

FROM nginxinc/nginx-unprivileged:1.19-alpine

USER root

# Create a group and user
RUN addgroup -S apache && adduser -S apache -G apache

RUN addgroup nginx www-data

RUN apk add php7 
    php7-fpm 
    php7-mysqlnd 
    nano

USER nginx
COPY webfiles/ /usr/share/nginx/html

USER root
COPY configfiles/nginx.conf     /etc/nginx/nginx.conf
# COPY configfiles/nginx2.conf     /etc/nginx//nginx2.conf
COPY configfiles/php.ini        /etc/php7/php.ini
COPY configfiles/www.conf       /etc/php7/php-fpm.d/www.conf
COPY configfiles/php-fpm.conf   /etc/php7/php-fpm.conf
# COPY configfiles/supervisord.conf /etc/supervisord.conf

# RUN rm -f /usr/share/nginx/html/index.html && 
#   chmod +x /docker-entrypoint.sh

RUN mkdir -p /usr/sbin/php-fpm

EXPOSE 8080

USER nginx

php:

FROM php:fpm

RUN mkdir -p /usr/share/nginx/html
RUN docker-php-ext-install mysqli

COPY index.php /usr/share/nginx/html/index.php
COPY action.php /usr/share/nginx/html/action.php

EXPOSE 9000

And here is my nginx.conf:

server {
        listen       8080 default_server;
        listen       (::):8080 default_server;
        index        index.php;
        server_name  web.cyber.test;
        root         /usr/share/nginx/html;

    error_log /var/log/nginx/error.log;

        # Load configuration files for the default server block.
        # include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
        
    location ~ .php$ {
        try_files $uri =404;
        fastcgi_pass 203.0.113.100:9000;
        fastcgi_index index.php;
        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
        include fastcgi_params;
        }