I got two apache containers connect to the same bridge network. First apache 172.20.10.2 and port 8080 (internally 80) Second apache 172.20.10.6 and port 9999 (internaly 80).
First apache is configured with two virtual hosts on port 80. First vhost support mydomain.com on that apache and everything works correctly. Second vhost support subdomain.mydomain.com and redirect to second apache server. This redirects don't work and on logs I got that error:
"GET /favicon.ico HTTP/1.1" 502 360
[proxy:error] [pid 43:tid 3028272160] (111)Connection refused: AH00957: http: attempt to connect to 172.20.10.6:9999 (172.20.10.6) failed
[proxy_http:error] [pid 43:tid 3028272160] [client Client_IP:PORT] AH01114: HTTP: failed to make connection to backend: 172.20.10.6
"GET / HTTP/1.1" 503 299
[proxy:error] [pid 8:tid 3011486752] [client Client_IP:PORT] AH00898: DNS lookup failure for: 172.20.10.6:9999favicon.ico returned by /favicon.ico, referer: http://subdomain.mydomain.com/
"GET /favicon.ico HTTP/1.1" 502 360
docker-compose.yml
version: "3.8"
volumes:
httpd_all:
httpd_all_2:
networks:
frontend_web:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.20.10.0/29
services:
httpd:
container_name: httpd
image: httpd:latest
hostname:
srv_www01
ports:
- 8080:80/tcp
- 8043:443/tcp
volumes:
- httpd_all:/usr/local/apache2/
networks:
frontend_web:
ipv4_address: 172.20.10.2
restart: unless-stopped
httpd_2:
container_name: httpd_2
image: httpd:latest
hostname:
srv_www02
ports:
- 9999:80/tcp
- 9998:443/tcp
volumes:
- httpd_all_2:/usr/local/apache2/
networks:
frontend_web:
ipv4_address: 172.20.10.6
restart: unless-stopped
vhosts on first apache 172.20.10.2
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias mydomain.com
DocumentRoot /usr/local/apache2/htdocs
Alias /jasno "/usr/local/apache2/htdocs"
</VirtualHost>
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ServerAlias www.subdomain.mydomain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
ProxyPass "/" "http://172.20.10.6:9999"
ProxyPassReverse "/" "http://172.20.10.4:9999"
</VirtualHost>