DEV Community

Abel Lifaefi Mbula
Abel Lifaefi Mbula

Posted on

Docker 403 error with apache

Hi!

I am setting up a simple Apache server for my php project. Although everything seems to be well done, I am getting a forbidden message when trying to access the server on the browser.

The problem happens when I try to add a volume. You can see my Dockerfile here:

FROM php:7.3-apache

COPY . /srv/app 
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /srv/app

RUN chown -R www-data:www-data /srv/app \
    && a2enmod rewrite \
    && chown -R 775 /srv/app \
    && ls -al /srv/app
Enter fullscreen mode Exit fullscreen mode

My docker-compose looks like this

version: '3'
services:
  app:
    build:
      context: .
      dockerfile: .docker/Dockerfile
    image: apache-docker
    ports:
      - 7070:80   
    volumes:
      - .:/srv/app:z 
Enter fullscreen mode Exit fullscreen mode

If I comment the volume instruction everything is OK.

Can you tell me if there is something wrong with my config?

Edit

The vhost.conf

<VirtualHost *:80>
    DocumentRoot /srv/app/web

    <Directory "/srv/app/web">
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
josephtaylor profile image
J. Taylor O'Connor

what’s in vhost.conf?

Collapse
 
bam92 profile image
Abel Lifaefi Mbula

I just edited the post to add vhost.conf