CentOS 7 httpd 无法与后端建立连接

Cod*_*Med 4 centos ssl tomcat apache-httpd reverse-proxy

在设置为for的CentOS 7服务器中,我收到一条错误消息,表明无法与. 如何解决此错误,以便 httpd 提供由 tomcat 生成的内容?apache httpd 2.4ssl reverse proxytomcathttpdtomcat

ssl_error_log说:

[Tue Dec 16 20:20:15.007630 2014] [proxy:error] [pid 12784] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed
[Tue Dec 16 20:20:15.007727 2014] [proxy:error] [pid 12784] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 60s
[Tue Dec 16 20:20:15.007752 2014] [proxy_http:error] [pid 12784] [client client.ip.address:48100] AH01114: HTTP: failed to make connection to backend: localhost
Run Code Online (Sandbox Code Playgroud)

我已经阅读了该catalina.out文件,它清楚地表明tomcat在我运行startup.sh. 我也读了这篇其他帖子,把责任推到了上面SELinux。但我确定/etc/sysconfig/selinuxSELINUX=disabled,所以我的问题似乎是由其他原因引起的。

reverse proxy今天的工作非常早。今天在服务器上所做的唯一变化是对根战争的新版本上传到tomcat了几次,并停止然后restart tomcathttpd每个新的根战争上传时间。这可能涉及将shutdown portinserver.xml从 -1 更改为有效的端口号以允许tomcat关闭。

您可以ssl.conf 通过单击此链接查看完整内容。请注意,VirtualHost完全定义在 中ssl.conf而不是在 中httpd.conf。您还可以server.xml 通过单击此链接阅读完整内容。

编辑:

按照 IanMcGowan 的建议给出了以下结果:

[root@remote.server.ip ~]# telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root@remote.server.ip ~]# GET / HTTP/1.0
<HTML>
<HEAD>
<TITLE>Directory /</TITLE>
<BASE HREF="file:/">
</HEAD>
<BODY>
<H1>Directory listing of /</H1>
<UL>
<LI><A HREF="./">./</A>
<LI><A HREF="../">../</A>
<LI><A HREF=".autorelabel">.autorelabel</A>
<LI><A HREF=".readahead">.readahead</A>
<LI><A HREF="bin/">bin/</A>
<LI><A HREF="boot/">boot/</A>
<LI><A HREF="db/">db/</A>
<LI><A HREF="dev/">dev/</A>
<LI><A HREF="etc/">etc/</A>
<LI><A HREF="home/">home/</A>
<LI><A HREF="lib/">lib/</A>
<LI><A HREF="lib64/">lib64/</A>
<LI><A HREF="media/">media/</A>
<LI><A HREF="mnt/">mnt/</A>
<LI><A HREF="opt/">opt/</A>
<LI><A HREF="proc/">proc/</A>
<LI><A HREF="root/">root/</A>
<LI><A HREF="run/">run/</A>
<LI><A HREF="sbin/">sbin/</A>
<LI><A HREF="srv/">srv/</A>
<LI><A HREF="sys/">sys/</A>
<LI><A HREF="tmp/">tmp/</A>
<LI><A HREF="usr/">usr/</A>
<LI><A HREF="var/">var/</A>
<LI><A HREF="www/">www/</A>
</UL>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)

我也打开8080测试tomcat是否运行如下:

当我输入http : / / mydomain.comand 时http : / / my.ip.address,浏览器没有任何内容。当我输入 时https : / / mydomain.com,我收到同样的错误,指出服务不可用。

最后两行catalina.out自从我昨天重启服务器后没有改变,如下:

16-Dec-2014 20:19:35.967 INFO [localhost-startStop-1] org.apache.catalina.start$
16-Dec-2014 20:19:35.970 INFO [main] org.apache.catalina.startup.Catalina.start$ Server startup in 46065 ms
Run Code Online (Sandbox Code Playgroud)

编辑#2:

为了测试 tomcat 是否正在运行,我执行了以下操作:

[root@remote.server.ip]# ps aux | grep tomcat
root      6858  0.7 18.5 3826248 1095780 ?     Sl   Dec12  51:03 java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
root     12524  0.2 20.1 3891788 1187888 ?     Sl   Dec15   6:20 java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
root     16404  0.2 15.0 3630784 887836 ?      Sl   Dec16   2:36 java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
root     17987  0.0  0.0 112640   964 pts/0    R+   14:20   0:00 grep --color=auto tomcat
Run Code Online (Sandbox Code Playgroud)

小智 6

要解决这个问题,首先通过动态设置布尔值来测试(还不是永久性的):

/usr/sbin/setsebool httpd_can_network_connect 1
Run Code Online (Sandbox Code Playgroud)

如果可行,您可以设置它以便更改默认策略,并且此设置将在重新启动后保持不变:

/usr/sbin/setsebool -P httpd_can_network_connect 1
Run Code Online (Sandbox Code Playgroud)

信用:https : //web.archive.org/web/20190313023936/http : //sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/