skip to Main Content

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


  1. Please refer https://docs.docker.com/network/network-tutorial-standalone/

    It should be configured :

    <VirtualHost *:80>
      ServerName localhost
      ProxyPass / http://172.17.0.1:8087
    </VirtualHost>
    

    or :

    <VirtualHost *:80>
          ServerName localhost
          ProxyPass / http://ip_addressof_my-server-container:8087
    </VirtualHost>
    

    Use: docker inspect container_id to see ip address of container.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. You can pack everything in a docker compose then you can use the container name:

    RedirectMatch ^/$ /mylocation/
    <Location /mylocation>
        Require all granted
        ProxyPass http://containername:8087/mylocation nocanon
        ProxyPassReverse http://containername:8087/mylocation
    </Location>
    

    Where containername is the name in the service:

    version: '2'
    services:
      apache:
        image: apache:2.4
        ports:
          - 80:8080
          - 443:8443
      containername:
        image: xxx:x.y.z
        ports:
          - 8087:8087
    

    UPDATE: If you get issues after the update of a container check:
    Apache proxypass IP addresses cached

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search