AH01114:HTTP:无法连接到后端:localhost(apache作为docker容器)

问题描述 投票:0回答:1

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

apache和服务器应用程序都作为docker容器运行。

启动我的服务器应用程序工作正常,我可以访问web-ui:

http://localhost:8087

但是当我启动apache并尝试在浏览器中访问它时:

http://localhost:80

我明白了:

Service Unavailable

当我看到日志时,它说:

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详细信息:

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>

这就是我启动服务器应用程序的方式:

docker run --network sample-network -p 0.0.0.0:8087:8087 -ti -d --name my-server-container my-server-image

这就是我启动apache的方式:

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

我的配置是在httpd.conf文件中还是在docker中运行命令(或两者的组合)?

apache docker
1个回答
1
投票

请参考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地址。

© www.soinside.com 2019 - 2024. All rights reserved.