Reputation: 2848
I'm creating test application with Laravel and Docker.
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.
Upvotes: 4
Views: 1616
Reputation: 2848
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"
...
Upvotes: 4