I am trying to setup apache in front of a server application (JIRA) on my local machine. Somewhat based on:
https://mimiz.github.io/2017/05/18/Configure-docker-httpd-image.html
Both apache and the server application are run as docker containers.
Starting my server application works fine and I can access the web-ui at:
http://localhost:8087
But when I start apache and try to access it in my browser:
http://localhost:80
I get:
Service Unavailable
and when I look at the logs it says:
H00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.5. Set the 'ServerName' directive globally to suppress this message
[Mon Apr 01 09:08:50.408757 2019] [mpm_event:notice] [pid 1:tid 140140879032384] AH00489: Apache/2.4.38 (Unix) configured -- resuming normal operations
[Mon Apr 01 09:08:50.409320 2019] [core:notice] [pid 1:tid 140140879032384] AH00094: Command line: 'httpd -D FOREGROUND'
[Mon Apr 01 09:09:53.094495 2019] [proxy:error] [pid 8:tid 140140638869248] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8087 (localhost) failed
[Mon Apr 01 09:09:53.094571 2019] [proxy_http:error] [pid 8:tid 140140638869248] [client 172.18.0.1:53110] AH01114: HTTP: failed to make connection to backend: localhost
This is httpd.conf details I have enabled/added:
LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
...
<VirtualHost *:80>
ServerName www.app1.lol
ProxyPass / http://localhost:8087
</VirtualHost>
And this is how I start my server application:
docker run --network sample-network -p 0.0.0.0:8087:8087 -ti -d --name my-server-container my-server-image
And this is how I start apache:
docker run -d -p 80:80 --network sample-network --name my-apache-container my-apache-image
Is the problem my configuration in the httpd.conf file or in the docker run commands (or a combination of both)?
3
Answers
Please refer https://docs.docker.com/network/network-tutorial-standalone/
It should be configured :
or :
Use:
docker inspect container_id
to see ip address of container.Face exact same issue, for me in redhat and debian both resolved by below command
sudo iptables -I INPUT 1 -i lo -j ACCEPT
Loopback need to enable this way.
Note: Due to some security reason it default disable, we need to enable it
You can pack everything in a docker compose then you can use the container name:
Where
containername
is the name in the service:UPDATE: If you get issues after the update of a container check:
Apache proxypass IP addresses cached