IndexZero
IndexZero

Reputation: 314

Laravel Docker - This site can't be reached -refused to connect

I'm in the process of transferring a Laravel project to docker in order to develop locally. It runs on the web server but won't run properly in docker. I get 'This site can't be reached' after I am redirected to the login view.

I can see all the files mounted in the container, the document root is correct, and I have no active firewalls.

mounted 000-default.conf:


<VirtualHost *:80>

        ServerAdmin testmate-dev.com.au
        ServerName www.testmate-dev.com.au
        DocumentRoot /home/beanstalk/laravel/public

        <Directory /home/beanstalk/laravel>
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:433>

        ServerAdmin testmate-dev.com.au
        ServerName www.testmate-dev.com.au
        ServerAlias www.testmate-dev.com.au
        DocumentRoot /home/beanstalk/laravel/public

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /home/beanstalk/laravel>
                AllowOverride All
                Require all granted
        </Directory>

</VirtualHost>

Since it runs on the webserver I believe it is some configuration issue however it correctly redirects to /login and then fails to construct the view.

Any way I can debug this/obvious errors would be appreciated. I can provide more context/files if needed.

Edit:
docker-compose.yml:

version: '3.7'
services:
  mysql-server:
    platform: linux/x86_64
    image: mysql:8.0.25
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: secret
    ports:
      - "3306:3306"
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:4.9.7
    depends_on:
      - mysql-server
    restart: always
    environment:
      PMA_HOST: mysql-server
      PMA_USER: root
      PMA_PASSWORD: secret
      UPLOAD_LIMIT: 700M
      PMA_ARBITRARY: 1
    ports:
      - 8081:80
  php:
    build:
      context: .
      network: host
      dockerfile: Dockerfile
    depends_on:
      - mysql-server
    ports:
      - 80:80
    volumes:
      - ./:/home/beanstalk/laravel/
      - ./apache/000-default.conf:/etc/apache2/sites-enabled/000-default.conf

Dockerfile:

FROM php:8.1-apache
WORKDIR /home/beanstalk/laravel
RUN docker-php-ext-install mysqli
RUN a2enmod headers
RUN mkdir -p  /home/logs/
RUN touch /home/logs/access.log
RUN touch /home/logs/error.log
RUN mkdir -p /home/beanstalk/laravel
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN apt-get update -y && apt-get install -y sendmail libpng-dev

RUN apt-get update && \
    apt-get install -y \
        zlib1g-dev \
        libzip-dev \
        zip
RUN docker-php-ext-install zip
RUN docker-php-ext-install gd

Upvotes: 1

Views: 1076

Answers (1)

IndexZero
IndexZero

Reputation: 314

changing RUN a2enmod headers to RUN a2enmod rewrite headers And using HTTP instead of HTTPS resolved my issues.

Upvotes: 1

Related Questions