This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Where does the <Connector> config information go? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Where does the <Connector> config information go?" Watch "Where does the <Connector> config information go?" New topic
Author

Where does the <Connector> config information go?

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

I'm trying to connect Apache HTTPD to Tomcat6 using mod_proxy

I can't figure out which config file to modify for the Connector element, i.e. stuff like:



Does it go in catalina.properties? or one of the various XML files? If one of the XML, which one?

Thanks
Pat
tanuj khare
author
Ranch Hand

Joined: May 02, 2012
Posts: 37
Connector configuration is configured in server.xml. This file can be found in TOMCAT_HOME/conf


Regards, Tanuj Khare
author of Apache Tomcat 7 Essentials
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

tanuj khare wrote:Connector configuration is configured in server.xml. This file can be found in TOMCAT_HOME/conf


Thanks. its /etc/tomcat6 on my distro.

Is there a specific section it belong in/under?
tanuj khare
author
Ranch Hand

Joined: May 02, 2012
Posts: 37
In the connector section, open the server.xml and search for connector port
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

I've found three active Connetor sections in my server.xml (with two more commented out)
(Debian Squeeze is the OS).



None of these have the Proxy arguments.

Can I just use port 8080 from mod_proxy to Tomcat? I've been testing directly into Tomcat using that port.
Or should I open up and define another port for the hTTPD to Tomcat communication?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

The proxy port is 8009 in the out-of-the-box server.xml. That's what you want to target in your proxy config in httpd. It's automatically useful "as is" with no configuration needed.


Customer surveys are for companies who didn't pay proper attention to begin with.
tanuj khare
author
Ranch Hand

Joined: May 02, 2012
Posts: 37
I agree with Tim
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Tim Holloway wrote:The proxy port is 8009 in the out-of-the-box server.xml. That's what you want to target in your proxy config in httpd. It's automatically useful "as is" with no configuration needed.


Not for me. Debian Squeeze's install comments that out.
I commented it in, and tried it both with and without the proxyName and proxyPort

my apache2.conf has:




and my server.xml looks like:

<Connector port="8009" protocol="AJP/1.3"
proxyName="my.wayfinderdigital..com"
proxyPort="80"
redirectPort="8443" />


Browser trying to use it gets a 500 internal server error,
the apache log looks like:


[Fri May 11 19:34:42 2012] [notice] Apache/2.2.16 (Debian) mod_jk/1.2.30 configured -- resuming normal operations
[Fri May 11 19:34:50 2012] [warn] proxy: No protocol handler was valid for the URL /webapi. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.


Any pointers or ideas as to what I am doing wrong greatly appreciated.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

I don't know where you got proxy name and port 80 from. I think you're mixing in some other proxy mechanism entirely - probably one going in the wrong direction and intended for an entirely different use. My connector is as follows:


And my proxy directive in Apache is:


Note that the proxy protocol is "ajp" and not http.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Tim Holloway wrote:I don't know where you got proxy name and port 80 from....
Note that the proxy protocol is "ajp" and not http.


I've been trying to find documentation of this from all over the web.
Proxy name and port directly from Tomcat's documentation:
http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html

I'll give your setup a try.

Thanks
pat
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

It has been a while since I had to RTFM on that.

I didn't need the proxy host and port options, since I was using the defaults (localhost, port 80). Item #6 on that page is confusing, however. It doesn't actually mean you can proxy to port 8080, it means that incoming direct requests to port 8080 AND incoming proxied requests coming in on port 8009 are treated identically.

They also unfortunately didn't provide a complete Connector directive, but I suspect that it wouldn't have included the AJP setting in my example. AJP might simply be an anachronism at this point.

To eliminate your HTTP 500 error, make sure that the Apache HTTP config also includes a LoadModule for the proxy. There is a prototype proxy master config file in the CentOS distro that does that and it's where I got my model proxypass statements from. It looks like this:


I also have a "SSLProxyEngine on" directive to ensure that SSL gets proxied as well.


Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Tim Holloway wrote:LoadModule proxy_ajp_module modules/mod_proxy_ajp.so


I thought that was the Apache 1 style, and with Apache2, you just put a link in mods_enabled to mods_available

This is Tomcat6, if that makes any difference.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

Tomcat6 is OK. But you're talking Debian-style Apache config and the Red Hat/CentOS/Fedora configs (which is what I'm referencing) aren't quite so civilized, alas. As long as you can find a module switch-in to do the LoadModule, use it. If not, make one of your own.
 
Consider Paul's rocket mass heater.
 
subject: Where does the <Connector> config information go?
 
Similar Threads
Simulate HTTPS in Tomcat connector or Apache config?
SSL on Tomcat -- No, not your typical question!
Tomcat rediretion - Domain
Unable to login to manager GUI
problem in starting tomcat with eclipse