0

I have installed httpd and tomcat on my server but somehow I'm not able to connect them.

<VirtualHost *:80>
        ServerName www.harshrathod.dev
        ServerAlias harshrathod.dev
        ServerAdmin ******************
        DocumentRoot /var/www/html
        DirectoryIndex index.html
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.harshrathod.dev [OR]
RewriteCond %{SERVER_NAME} =harshrathod.dev
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

ProxyRequests off
ProxyPass /projects/legend ajp://localhost:8009/legend
ProxyPassReverse /projects/legend ajp://localhost:8009/legend

</VirtualHost>

Accessing the legend page on harshrathod.dev shows error instead of responding with the index.jsp page in "../webapps/legend". Both the servers are up and running. HTTPD is listenng on 80 and tomcat on localhost:8080

Do I need to paste this on:

ProxyRequests off
ProxyPass /projects/legend ajp://localhost:8009/legend
ProxyPassReverse /projects/legend ajp://localhost:8009/legend

in httpd-le-ssl.conf ?

There are these errors related to proxy on error_log

[Sun Mar 29 17:13:28.909192 2020] [proxy:error] [pid 6690] (70007)The timeout specified has expired: AH00957: AJP: attempt to connect to 120.0.0.1:8009 (120.0.0.1) failed
[Sun Mar 29 17:13:28.909285 2020] [proxy_ajp:error] [pid 6690] [client 27.56.193.67:10405] AH00896: failed to make connection to backend: 120.0.0.1, referer: https://harshrathod.dev/
[Sun Mar 29 17:18:19.513513 2020] [proxy:error] [pid 6659] (70007)The timeout specified has expired: AH00957: AJP: attempt to connect to 120.0.0.1:8009 (120.0.0.1) failed
[Sun Mar 29 17:18:19.513582 2020] [proxy_ajp:error] [pid 6659] [client 103.125.234.198:57195] AH00896: failed to make connection to backend: 120.0.0.1, referer: https://harshrathod.dev/
  • Can you include the error it returns in your question as well as any relevant output from your apache error log? – gnubeard Mar 29 '20 at 20:47
  • 1
    The naming of Apache's secondary config files is not canonical (they are all included from the main config), but if `httpd-le-ssl.conf` contains the SSL `` you should put the `ProxyPass` and related directives there. – Piotr P. Karwasz Mar 29 '20 at 20:50
  • I have added the errors related to proxy. The connection is failing. – harshrathod50 Mar 30 '20 at 04:10
  • Check whether Tomcat is running and you have a `` element of type AJP/1.3 in `server.xml`. – Piotr P. Karwasz Mar 30 '20 at 04:36
  • Now I have moved: ProxyRequests off ProxyPass /projects/legend ajp://localhost:8009/legend ProxyPassReverse /projects/legend ajp://localhost:8009/legend to httpd-el-ssl.conf – harshrathod50 Mar 30 '20 at 04:40
  • Yes, there is a connector element in server.xml . And it is working fine. I have tested it using "wget". It is responding with index.jsp in "../webapps/legend". But the proxy stuff is not working. – harshrathod50 Mar 30 '20 at 04:42
  • Thankyou so much, moving worked. Can you post your comment as answer. I will upvote it. Thankyou so much Mr. Karwasz. I appreciate your time. – harshrathod50 Mar 30 '20 at 04:46

1 Answers1

0

Your <VirtualHost *:80> is set up to redirect everything to port 443 (at least for the harshrathod.dev and www.harshrathod.dev domains), so the ProxyPass directive will never be executed.

As you suggest in your question, you should move the ProxyPass and related directives to your <VirtualHost *:443>.

Remark also, that Tomcat's HTTP/1.1 <Connector> on port 8080 is not used in this configuration. You use the AJP/1.3 <Connector> on port 8009 instead, which is a faster protocol. If you would like to use the (slower) HTTP/1.1 <Connector> use:

ProxyPass /projects/legend http://localhost:8080/legend
ProxyPassReverse /projects/legend http://localhost:8080/legend
Piotr P. Karwasz
  • 5,292
  • 2
  • 9
  • 20