In a CentOS 7 server, I am trying to set up httpd to act as a reverse proxy for tomcat. I have httpd running perfectly in the sense that I type in http/mydomain.com and it serves up static content located in the designated DocumentRoot. I also have tomcat running perfectly in that tomcat serves up a designated war file when I type in http/my.server.ip:8080. The war file redirects all unauthenticated users to the /login url pattern so they can sign in before using the site. This works fine in tomcat. But when I comment out the DocumentRoot and add ProxyPass and ProxyPassReverse instead, I get the following error message in the browser:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /login.

Reason: DNS lookup failure for: server.ip.address:8009login

My VirtualHost is as follows:

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    ErrorLog /var/log/httpd/mydomain_com_error.log
    CustomLog /var/log/httpd/mydomain_com_requests.log combined
    ProxyPass / ajp://server.ip.address:8009
    ProxyPassReverse / ajp://server.ip.address:8009

I also made sure to uncomment the following connector in server.xml:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

You can read the entire server.xml file located in a file sharing site by clicking on this link.

Apache is obviously talking to tomcat and working with the war file, because apache figured out how to get re-directed to the /login url pattern. But how can I fix my configuration so that /login and other relative urls get served correctly?

I am not certain whether or not mod_jk is installed.

  • Glad you got all this working. You're on the final step... I must ask though: Where does login come from in server.ip.address:8009login – eyoung100 Dec 26 '14 at 20:35
  • @eyoung100 When a user who has not been authenticated by the java application/war requests any url in the app, that user is redirected by the app to the /login url pattern. In this case, the user is requesting the / url pattern. But since the user has not logged in to the app yet, the request is redirected to /login. – CodeMed Dec 26 '14 at 21:25
  • Well then you forgot a space – eyoung100 Dec 26 '14 at 21:35
  • @eyoung100 where? – CodeMed Dec 26 '14 at 21:35
  • server.ip.address:8009login That string is not terminated properly The server thinks the port is 8009login – eyoung100 Dec 26 '14 at 21:37

Append a / to both your ProxyPass lines as it seems that tomcat is redirecting to login instead of /login. Use:

ProxyPass / ajp://server.ip.address:8009/
ProxyPassReverse / ajp://server.ip.address:8009/
  • This helps me understand that tomcat is just concatenating a string, then passing the assembled string into another function. – CodeMed Dec 27 '14 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.