Apache a2enconf in a Docker container

Viewed 9246

I'm trying to follow this code obtained in this tutorial, without success.

On my local machine, I get it to work (although I had to modify the rewrite rules). But when trying to use a Docker container, I get error 404 when I try to access the example REST resources:

$docker-compose logs -f

web_1  | 172.27.0.1 - - [19/Jul/2017:17:45:58 +0000] "GET /clients/jim HTTP/1.1" 404 501 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"
web_1  | 172.27.0.1 - - [19/Jul/2017:17:46:20 +0000] "GET /clients/anne HTTP/1.1" 404 502 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"

It seems to me that the error happens with a2enconf, since it works if I use an .htaccess file and add the following line involumes:

- "./code/rest.conf:/var/www/html/.htaccess:Z"

Dockerfile

FROM php:5.6-apache
RUN a2enmod rewrite
COPY rest.conf /etc/apache2/conf-available/
RUN a2enconf rest

rest.conf

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ server.php

docker-compose.yml

version: '2'
services:
  web:
    image: myphp:5.6-apache-rewrite
    ports:
      - "80:80"
    volumes:
      - "./code/server.php:/var/www/html/server.php:Z"
    restart: unless-stopped

Inside the container

# apache2ctl -t

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
Syntax OK

# apache2ctl -M
Loaded Modules:
(...)
 rewrite_module (shared)
(...)

# apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   172.27.0.2 (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
1 Answers
Related