AH01114:HTTP:无法建立与后端的连接:localhost(Apache作为Docker容器) [英] AH01114: HTTP: failed to make connection to backend: localhost (apache as docker container)

查看:1450
本文介绍了AH01114:HTTP:无法建立与后端的连接:localhost(Apache作为Docker容器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地计算机上的服务器应用程序(JIRA)前面设置apache。基于某种程度:
https:// mimiz.github.io/2017/05/18/Configure-docker-httpd-image.html

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

apache和服务器应用程序均作为docker运行

Both apache and the server application are run as docker containers.

启动我的服务器应用程序工作正常,我可以在以下位置访问Web界面:

Starting my server application works fine and I can access the web-ui at:

http://localhost:8087

但是当我开始使用Apache并尝试在我的浏览器中访问它:

But when I start apache and try to access it in my browser:

http://localhost:80

我得到:

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

这是我已启用/添加的 httpd.conf 详细信息:

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

这就是我开始apache的方式:

And this is how I start apache:

docker run -d -p 80:80 --network sample-network --name my-apache-container my-apache-image

我的 httpd.conf 文件或docker run命令(或两者的组合)中的配置是否有问题?

Is the problem my configuration in the httpd.conf file or in the docker run commands (or a combination of both)?

推荐答案

请参考 https://docs.docker.com/network/network-tutorial-standalone/

应进行配置:

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

或:

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

使用: docker inspect container_id 来查看ip容器的地址。

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

这篇关于AH01114:HTTP:无法建立与后端的连接:localhost(Apache作为Docker容器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆