0

My First post is done here: Docker environment for PHP Framework from scratch Because I solved the first problem and I can't update or reuse a post, I prefer to create a new post with the new question from the same scenario, the scenario has some changes.

I need help to create my development environment in docker I have several errors implement this stack and I do not achieve my goal. I'm looking to get that working.

I will explain and share everything I am trying

  1. Software used:

Windows 10 as Host.
Laragon (Nginx for reverse proxy)
Docker Desktop last Updated.

  1. Diagram estructure:

Diagram //need rep to public image.

  1. hosts file in windows System:
    127.0.0.1 minos.dock www.minos.dock
    127.0.0.1 phpmyadmin.dock www.phpmyadmin.dock
  1. Reverse Proxy in nginx file config: NOTE: I'm not quite sure if this is configured correctly.
server {
    server_name minos.dock;

    location / {
        proxy_pass localhost:8008;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout       5000;
        proxy_send_timeout          5000;
        proxy_read_timeout          5000;
        send_timeout                5000;
        fastcgi_send_timeout        5000;
        fastcgi_read_timeout        5000;
    }
}
  1. Project File Structure:
Minos
│   .dockerignore
│   composer.json
│   composer.lock
│   docker-compose.yml    //docker-compose yml file
│   Dockerfile            //Dockerfile
│   index.php             //for Testing reach this point.
│
├───conf-example          //for example files
│       apache.conf       //use this on Docker Build
│
├───envlog                //for Error server and PHP logs
├───public                //public folder dicoumento root
│       index.php         //for Testing reach this point.
│
└───vendor 
    │   autoload.php
    │
    ├───composer
    │       autoload_classmap.php
    │       autoload_namespaces.php
    │       autoload_psr4.php
    │       autoload_real.php
    │       autoload_static.php
    │       ClassLoader.php
    │       installed.json
    │       installed.php
    │       InstalledVersions.php
    │       LICENSE
    │       platform_check.php
    │
    └───phpmailer
        └───phpmailer
            │   COMMITMENT
            │   composer.json
            │   get_oauth_token.php
            │   LICENSE
            │   README.md
            │   SECURITY.md
            │   VERSION
            │
            ├───language
            │       phpmailer.lang-es.php
            │
            └───src
                    Exception.php
                    OAuth.php
                    OAuthTokenProvider.php
                    PHPMailer.php
                    POP3.php
                    SMTP.php
  1. Content of apache.conf for docker: NOTE: I'm not quite sure if this is configured correctly.
<VirtualHost *:80>
    
    #Server Config
    DirectoryIndex index.php
    DocumentRoot /var/www/public
    
    #Error Log
    ErrorLog /var/www/envlog/apache-error.log
    CustomLog /var/www/envlog/apache-access.log combined
    php_value error_log /var/www/envlog/php-error.log
    
    #Server Default Access
    <Directory /var/www/public>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
  1. Content of docker-composer.yml for docker:
version: "3.8"
services:
  app:
    tty: true
    container_name: 'minos-php'
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8008:80"
    volumes:
      - ./public:/var/www/public/
      - .:/var/www
    depends_on:
      - mysql
    links:
      - mysql
  mysql:
    container_name: 'minos-mysql'
    image: arm64v8/mysql:oracle
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - mysql-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "33060:3306"
volumes:
  mysql-data:
  1. Content of Dockerfile for docker:
FROM ubuntu:22.04
LABEL maintainer="ChaosEmperorDragonEnvoyoftheEnd"
LABEL version="1.0.0"

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV DATE_TIMEZONE UTC
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    git \
    mysql-client \
    nano \
    unzip \
    wget \
    zip \
    apache2 \
    libapache2-mod-php \
    libmcrypt-dev \
    cron \
    locales \
    php \
    php-cli \
    php-gd \
    php-common \
    php-curl \
    php-imap \
    php-intl \
    php-json \
    php-mailparse \
    php-mbstring \
    php-mysql \
    php-pear \
    php-readline \
    php-soap \
    php-xml \
    php-xmlrpc \
    php-zip \
    php-bz2 \
    php-dba \
    php-ldap \
    php-dev \
    php-memcached \
    php-xdebug \
 && rm -rf /var/lib/apt/lists/*

RUN a2enmod rewrite

# Setup project folder
COPY public /var/www
RUN chown -R www-data:www-data /var/www
RUN chmod -R 0775 /var/www

# Configure apache
# RUN a2enmod rewrite ssl
ADD conf-example/apache.conf /etc/apache2/sites-enabled/000-default.conf

# Configure PHP
#RUN echo 'apc.enable_cli=1' >>  /etc/php/8.1/cli/php.ini

RUN echo 'max_execution_time = 5000' >> /etc/php/8.1/cli/php.ini
RUN echo 'memory_limit = 2G' >> /etc/php/8.1/cli/php.ini
RUN echo 'post_max_size = 2G' >> /etc/php/8.1/cli/php.ini
RUN echo 'max_input_vars = 2000' >> /etc/php/8.1/cli/php.ini
RUN echo 'upload_max_filesize = 2G' >> /etc/php/8.1/cli/php.ini
RUN echo 'display_errors = on' >> /etc/php/8.1/cli/php.ini

# Setup for testing
RUN locale-gen es_ES.UTF-8

RUN apt-get clean

Problem List:

  1. when i try join to http://minos.dock/ i get this error:

502 Bad Gateway nginx/1.19.10

get this error:

but i not get any log file on envlog

Error 502 Bad Gateway can be anything... but I don't know how to find the problem, let me know and then look for a solution, I appreciate any help at this point to Solve This?

Update #1:

I seek the internal nginx log of laragon setup and get this:

2022/10/12 16:41:04 [error] 11100#16028: *7 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: minos.dock, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8008/", host: "minos.dock"

2022/10/12 16:41:04 [error] 11100#16028: *7 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: minos.dock, request: "GET / HTTP/1.1", upstream: "http://[::1]:8008/", host: "minos.dock"

2022/10/12 16:41:04 [error] 11100#16028: *7 no live upstreams while connecting to upstream, client: 127.0.0.1, server: minos.dock, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "minos.dock", referrer: "http://minos.dock/"

i has updated the nginx proxy reverse setting, and setup 3600s instead of 5000 integer and i continue getting that error.

0 Answers0