I have app based on Docker and microservices. Angular, MySQL, Lumen + Apache. Unfortunately on Docker my API doesn’t send any header or status code. Any response is 200. I tried change HTTP server to NGINX but for nothing. I have no idea how can i fix this issue.
Apache config
NameVirtualHost *:8080 Listen 8080 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
ServerName localhost:8080 <VirtualHost *:8080> DocumentRoot /var/www/html/public <Directory /var/www/html/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
Dockerfile
FROM php:7.4.1-apache # Arguments defined in docker-compose.yml ARG user ARG uid # Install system dependencies RUN apt-get update && apt-get install -y git curl libpng-dev zlib1g-dev libonig-dev libxml2-dev curl libzip-dev zip unzip #COPY .docker/apache.conf /etc/apache2/sites-available/000-default.conf # Clear cache RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install PHP extensions RUN docker-php-ext-configure gd RUN docker-php-ext-configure zip && docker-php-ext-install zip RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer RUN chown -R www-data:www-data /var/www/html RUN a2enmod rewrite headers cache # Create system user to run Composer and Artisan Commands RUN useradd -G www-data,root -u $uid -d /home/$user $user RUN mkdir -p /home/$user/.composer && chown -R $user:$user /home/$user # Set working directory WORKDIR /var/www/html USER $user EXPOSE 8080
docker-compose.yml
version: "3.7" services: backend: build: args: user: sammy uid: 1000 context: ./backend dockerfile: .docker/Dockerfile image: backend ports: - 8000:8080 container_name: backend restart: unless-stopped working_dir: /var/www/html volumes: - ./backend:/var/www/html - ./backend/.docker/apache.conf:/etc/apache2/sites-available/000-default.conf - ./backend/.docker/ports.conf:/etc/apache2/ports.conf networks: - jpk db: image: mysql:5.7 container_name: jpk-db restart: always ports: - "3306:3306" environment: MYSQL_DATABASE: 'jpk' MYSQL_ALLOW_EMPTY_PASSWORD: 1 MYSQL_ROOT_PASSWORD: "" volumes: - ./db:/var/lib/mysql networks: - jpk frontend: build: args: env: prod context: ./frontend dockerfile: Dockerfile image: frontend container_name: frontend ports: - "80:80" environment: NODE_ENV: production networks: jpk: driver: bridge
.htaccess
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> <IfModule mod_headers.c> SetEnvIf Origin "http(s)?://([^.]+.)?(mysite.com|mysite.local:4200|localhost:4200)$" AccessControlAllowOrigin=$0$1 Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header set Access-Control-Allow-Credentials true </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule>
Advertisement
Answer
Okey I found answer for my problem. I need to add line
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
in my Dockerfile