Apache2 Reverse Proxy configuration for Docker Containers
7,103
EDIT: Found out how to fix it, just had to edit /etc/hosts file
Original:
127.0.0.1 www.gitlab.ch
127.0.0.1 www.email.ch
Fixed:
172.17.0.2 www.gitlab.ch
172.17.0.3 www.email.ch
The problem was that i used the host machines local IP insted of the Docker Conatiners IP.
Author by
Marcel Ferrari
Updated on September 18, 2022Comments
-
Marcel Ferrari over 1 year
Let me start by saying i'm new to Apache2.
I'm trying to configure Apache2 as a Reverse Proxy for 2 Docker containers (Gitlab and a email service). My configuration is as follows:
<VirtualHost *:80> ProxyPreserveHost On # Servers to proxy the connection, or; # List of application servers: # Usage: # ProxyPass / http://[IP Addr.]:[port]/ # ProxyPassReverse / http://[IP Addr.]:[port]/ # Example: ProxyPass / http://172.17.0.2/ ProxyPassReverse / http://172.17.0.2/ ServerAlias www.gitlab.ch ServerName www.gitlab.ch </VirtualHost>
and
<VirtualHost *:443> ServerAdmin webmaster@localhost ProxyPreserveHost On # Servers to proxy the connection, or; # List of application servers: # Usage: # ProxyPass / http://[IP Addr.]:[port]/ # ProxyPassReverse / http://[IP Addr.]:[port]/ # Example: SSLProxyVerify none SSLProxyEngine on SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLProxyCheckPeerExpire off ProxyPass / https://172.17.0.2/ ProxyPassReverse / https://172.17.0.2/ ServerAlias www.gitlab.ch ServerName www.gitlab.ch
I have edited the /etc/hosts file.
The config files are set up exactly the same (except for name and IP address) but for some reason regardless of which link i follow (www.gitlab.ch or wwww.email.ch) , i always end up at the email login panel so i guess apache gives priority to that.
The port configuration is as follows (Host Machine:Container)
Gitlab:
8800:80 4433:443
Email:
2500:25 8000:80 4430:443 1100:110 1430:143 4650:465 5870:587 9930:993 9950:995
Any help is much appreciated.
-
muru almost 7 yearsPlease don't add "solved" etc., to the title. Instead, mark the answer as accepted, when you can.
-
Marcel Ferrari almost 7 yearsSorry, will do asap (have to wait 2 days).
-