4

I'm creating test application with Laravel and Docker.

Docker containers

I have 3 Docker containers: one Apache which using ProxyPass selecting one of other two containers and two containers which have Laravel applications.

I have also extra lines in /etc/hosts

127.0.0.1        auth.pi
127.0.0.1        worker.pi

My main (green) Apache's conf file is

<VirtualHost *:80>
    ServerName auth.pi

    ProxyPass / http://auth:80/
</VirtualHost>

<VirtualHost *:80>
    ServerName worker.pi

    ProxyPass / http://worker:80/
</VirtualHost>

In red's `.env I have

APP_URL=http://auth.pi

But when I used url('/') or route(...) my domain is http://auth/.

My red's Apache's conf

<VirtualHost *:80>
    ServerName auth.pi

    DocumentRoot /var/www/html/public

    <Directory "/var/www/html/public">
        AllowOverride all
    </Directory>

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

File docker-compose.yml contains:

services:
  apache:
    build: "./apache"
    container_name: "pi-apache"
    links:
      - "auth-apache:auth"
    ...
  auth-apache:
    build: "./applications/auth/apache"
    container_name: "pi-auth-apache"
    ...

What I do wrong? Why my red's Laravel app thinks that he is http://auth/ not http://auth.pi/?

In blue's app I have same configuration and same issue.

3
  • 1
    Update your docker-compose file with hostname so that containers can know what their hostname is. Commented Aug 19, 2017 at 9:15
  • @Ayushya I added domainname: "auth.pi" and hostname: "auth" in auth-apache service but this not helps. Commented Aug 19, 2017 at 9:22
  • Hostname should be able to identify containers as said in descriptions about aliases you might not be accessing it properly. Commented Aug 19, 2017 at 9:28

1 Answer 1

4

The problem is with green's conf

In VirtualHost section I must add

RequestHeader set Host "auth.pi"

ProxyPreserveHost On

Final VirtualHost for auth.pi

<VirtualHost *:80>
    ServerName auth.pi

    RequestHeader set Host "auth.pi"

    ProxyPreserveHost On

    ProxyPass / http://auth:80/
</VirtualHost>

I also added in docker-compose.yml

  auth-apache:
    build: "./applications/auth/apache"
    container_name: "pi-auth-apache"
    domainname: "pi"
    hostname: "auth"
    ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.