[apache] Httpd returning 503 Service Unavailable with mod_proxy for Tomcat 8

I'm trying to integrate Tomcat with Apache. My aim is to redirect all the requests with http://localhost/myapp to http://localhost:8080

I followed this guide: http://tomcat.apache.org/tomcat-8.0-doc/proxy-howto.html

My httpd.conf looks like this:

Include conf.modules.d/*.conf
LoadModule proxy_module  modules/mod_proxy.so

ProxyPass         /myapp  http://localhost:8080 retry=0 timeout=5
ProxyPassReverse  /myapp  http://localhost:8080

My server.xml in apache-tomcat looks like this:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" proxyPort="80" />

Now when I try the url http://localhost/myapp, it gives 503 Service Unavailable error.

Both Tomcat and Apache are up and running. The URL http://localhost:8080 works fine.

Can there be an issue with file permissions?

For tomcat the user and group are root/root and for httpd, the user and group are apache/apache

Am I missing something or am I doing it wrong?

Httpd version is 2.4.6 and Tomcat's version is 8.0

The httpd error logs:

[proxy:error] [pid 19905] (13)Permission denied: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed

[proxy:error] [pid 19905] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 0s

[proxy_http:error] [pid 19905] [client ::1:51615] AH01114: HTTP: failed to make connection to backend: localhost

Solved!

The answer is here: http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/

This question is related to apache tomcat

The answer is


(Answered by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

The answer is here: http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/

Which is a link to a blog that explains:

SELinux on RHEL/CentOS by default ships so that httpd processes cannot initiate outbound connections, which is just what mod_proxy attempts to do.

If this is the problem, it can be solved by running:

 /usr/sbin/setsebool -P httpd_can_network_connect 1

And for a more definitive source of information, see https://wiki.apache.org/httpd/13PermissionDenied


this worked for me:

ProxyRequests     Off
ProxyPreserveHost On
RewriteEngine On

<Proxy http://localhost:8123>
Order deny,allow
Allow from all
</Proxy>

ProxyPass         /node  http://localhost:8123  
ProxyPassReverse  /node  http://localhost:8123

Resolve issue Immediate, It's related to internal security

We, SnippetBucket.com working for enterprise linux RedHat, found httpd server don't allow proxy to run, neither localhost or 127.0.0.1, nor any other external domain.

As investigate in server log found

[error] (13)Permission denied: proxy: AJP: attempt to connect to
   10.x.x.x:8069 (virtualhost.virtualdomain.com) failed

Audit log found similar port issue

type=AVC msg=audit(1265039669.305:14): avc:  denied  { name_connect } for  pid=4343 comm="httpd" dest=8069 
scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:port_t:s0 tclass=tcp_socket

Due to internal default security of linux, this cause, now to fix (temporary)

 /usr/sbin/setsebool httpd_can_network_connect 1

Resolve Permanent Issue

/usr/sbin/setsebool -P httpd_can_network_connect 1

On CentOS Linux release 7.5.1804, we were able to make this work by editing /etc/selinux/config and changing the setting of SELINUX like so:

SELINUX=disabled

Questions with apache tag:

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer WAMP won't turn green. And the VCRUNTIME140.dll error MySQL error - #1932 - Table 'phpmyadmin.pma user config' doesn't exist in engine SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed resource error in android studio after update: No Resource Found XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04 installing apache: no VCRUNTIME140.dll Could not load the Tomcat server configuration How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M? Apache Server (xampp) doesn't run on Windows 10 (Port 80) How to set up file permissions for Laravel? Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error How to allow Cross domain request in apache2 Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat Netbeans 8.0.2 The module has not been deployed Only variable references should be returned by reference - Codeigniter laravel the requested url was not found on this server httpd-xampp.conf: How to allow access to an external IP besides localhost? WebSockets and Apache proxy : how to configure mod_proxy_wstunnel? How to force reloading php.ini file? XAMPP: Couldn't start Apache (Windows 10) how to create virtual host on XAMPP phpmyadmin "Not Found" after install on Apache, Ubuntu XAMPP installation on Win 8.1 with UAC Warning Httpd returning 503 Service Unavailable with mod_proxy for Tomcat 8 how to configure apache server to talk to HTTPS backend server? How to fix PHP Warning: PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll'? error running apache after xampp install How to enable local network users to access my WAMP sites? Apache Proxy: No protocol handler was valid OSError - Errno 13 Permission denied Project Links do not work on Wamp Server WAMP Cannot access on local network 403 Forbidden Apache 2.4 - Request exceeded the limit of 10 internal redirects due to probable configuration error How to enable CORS in apache tomcat Apache won't start in wamp Execute PHP script in cron job "End of script output before headers" error in Apache Starting of Tomcat failed from Netbeans Tomcat in Intellij Idea Community Edition

Questions with tomcat tag:

Jersey stopped working with InjectionManagerFactory not found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat Spring boot: Unable to start embedded Tomcat servlet container Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start Kill tomcat service running on any port, Windows Tomcat 8 is not able to handle get request with '|' in query parameters? 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE 403 Access Denied on Tomcat 8 Manager App without prompting for user/password Difference between Xms and Xmx and XX:MaxPermSize How to set the max size of upload file What is username and password when starting Spring Boot with Tomcat? How to use Tomcat 8.5.x and TomEE 7.x with Eclipse? Access Tomcat Manager App from different host Tomcat Server Error - Port 8080 already in use Server http:/localhost:8080 requires a user name and a password. The server says: XDB Could not load the Tomcat server configuration Deploying Java webapp to Tomcat 8 running in Docker container Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat Netbeans 8.0.2 The module has not been deployed org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]A child container failed during start A child container failed during start java.util.concurrent.ExecutionException Spring Boot War deployed to Tomcat Tomcat 8 Maven Plugin for Java 8 MySQL JDBC Driver 5.1.33 - Time Zone Issue Error starting Tomcat from NetBeans - '127.0.0.1*' is not recognized as an internal or external command java.net.BindException: Address already in use: JVM_Bind <null>:80 Httpd returning 503 Service Unavailable with mod_proxy for Tomcat 8 Increasing Heap Size on Linux Machines Tomcat - maxThreads vs maxConnections Can't start Tomcat as Windows Service There are No resources that can be added or removed from the server Checking Maven Version "Not allowed to load local resource: file:///C:....jpg" Java EE Tomcat org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 How to enable CORS in apache tomcat Starting of Tomcat failed from Netbeans SEVERE: Unable to create initial connections of pool - tomcat 7 with context.xml file Tomcat in Intellij Idea Community Edition org.glassfish.jersey.servlet.ServletContainer ClassNotFoundException http://localhost:8080/ Access Error: 404 -- Not Found Cannot locate document: / SEVERE: ContainerBase.addChild: start:org.apache.catalina.LifecycleException: Failed to start error Tomcat starts but home page cannot open with url http://localhost:8080 Launching Spring application Address already in use port 8080 is already in use and no process using 8080 has been listed how to start the tomcat server in linux? How can I specify my .keystore file with Spring Boot and Tomcat? How do you know if Tomcat Server is installed on your PC Unable to compile class for JSP: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files Tomcat Servlet: Error 404 - The requested resource is not available