Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-01-2010, 01:34 PM
|
#1
|
Member
Registered: Jul 2009
Posts: 36
Rep:
|
Tomcat problem
Hello everybody,
I'm kinda new to using Tomcat so I hope for your understanding.
I have a site called "app.testsite.com"
If i put it in the webapps-folder in centos 5.5 (standard installation, no nice home-built stuff) and restart tomcat I can browse to the site if I go to http://app.testsite.com:8080.
If I put in a iptables redirect rule from 80 to 8080 I can then browse the site if i go to http://app.testsite.com. No problem so far.
If I instead of iptables rule use xinetd to redirect port 80 to 8080 I get a problem. The problem is only a part of the site loads. A bigger part yes but still not the whole site.
If I install apache (on the same server) and use it as proxy and proxy the site with this:
ProxyPass / http://localhost:8080/
The same problem as with xinetd appears.
On the other hand... If I separate (two separate machines) the apache server (app.testsite.com) and the tomcat server (app.testsite2.com) and I use the iptables rule on the tomcat server to redirect 80 to 8080.
Then I set up the proxy on the apache server like this:
ProxyPass / http://app.testsite2.com
http://app.testsite.com works like a charm
Now... I actually can live with that considering I'm going to run the servers separated from each other anyway.
BUT WHY IS THIS HAPPENING?
Seriously, I don't just want to fix it, it's driving me crazy to se a problem I don't understand.
Is there anybody here who have a clue what this could be?
Should I do something in the ProxyPass setup to make it work?
Best regards
Johan
Last edited by dexznrl; 12-01-2010 at 01:39 PM.
|
|
|
12-01-2010, 03:03 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
it's happening because you are changing the HOST header at the point of proxy. From tomcat's perspective you are asking tomcat for the "localhost" website, not the "app.testsite.com" website, so it won't serve it. check this... http://httpd.apache.org/docs/current...xypreservehost
|
|
|
12-01-2010, 03:16 PM
|
#3
|
Member
Registered: Jul 2009
Posts: 36
Original Poster
Rep:
|
Firstly the tomcat server isn't set to care about http-headers.
Secondly the site loads... There are only a few things missing. The missing things aren't missed when I connect directly to the tomcat-server via port 8080 or port 80 through iptables redirect.
|
|
|
12-01-2010, 03:25 PM
|
#4
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Quote:
Originally Posted by dexznrl
Firstly the tomcat server isn't set to care about http-headers.
Secondly the site loads... There are only a few things missing. The missing things aren't missed when I connect directly to the tomcat-server via port 8080 or port 80 through iptables redirect.
|
Yeah, when you connect with the proper hostname... No?
So what parts are missing? It's not just going to be 'some' bits. What documents are being requested but not obtained? You might want a tool like firebug on firefox to see what the browser is doing.
|
|
|
12-01-2010, 03:38 PM
|
#5
|
Member
Registered: Jul 2009
Posts: 36
Original Poster
Rep:
|
Just to be sure about it I tried with proxypreservehost on without any success.
I can connect with the IP-address directly to tomcat if i want to.
Or I can set up a new hostname in my local hostfile on my laptop and connecto to it. As long as I use port 8080 or if i make a redirect rule in iptables 80>8080 it works. It stops working only if I proxy the site.
Xinetd has sort of a transparent proxy and when I use xinetd the same problem appears.
The tomcat server only serves one site. Nothing else.
I'm gonna take a look at it with that firebug thing and see if I can see anything.
The problem is narrowed down to this: As long as I go through a iptables redirect rule 80>8080 or directly through 8080 the page works perfectly.
But if I in any way try to proxy from 80 to 8080 the problem appears.
The site is running at the moment so I actually have all the time in the world to solve it.
|
|
|
12-01-2010, 03:55 PM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Well if it's working, why not just run tomcat on port 80 in the first place?
|
|
|
12-01-2010, 04:22 PM
|
#7
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep: 
|
Quote:
Originally Posted by dexznrl
If I install apache (on the same server) and use it as proxy and proxy the site with this:
ProxyPass / http://localhost:8080/
The same problem as with xinetd appears.
|
No sir. You want an AJP proxy for Tomcat. Here's an example config:
Code:
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
ProxyRequests Off
ProxyPass /foo/ ajp://localhost:8009/
Quote:
Originally Posted by acid_kewpie
... why not just run tomcat on port 80 in the first place?
|
That requires Tomcat to run as root. (Which OP may be OK with, but I try to avoid.  )
|
|
|
12-01-2010, 04:40 PM
|
#8
|
Member
Registered: Jul 2009
Posts: 36
Original Poster
Rep:
|
Think I found the problem...
It has something to do with jnlp, whatever that is. I have no clue but I found an error in the logs that pointed me in that direction.
Anyone with any ideas about how I can find the settings-file for the jnlp so I can change it to statically connect to the proxys address?
At the moment it tries to connect to the address that the proxy connects to when it connects to the tomcat, including the port number and port 8080 isn't reachable from the outside.
Suggestions anyone?
|
|
|
12-01-2010, 04:53 PM
|
#9
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,221
|
Hi,
For apache to work as a reverse proxy you need the following:
Code:
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
Regards
Last edited by bathory; 12-01-2010 at 05:00 PM.
|
|
|
12-02-2010, 01:55 AM
|
#10
|
Member
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749
Rep:
|
For tomcat, if you wanna use AJP, you can also use mod_jk. It might not be the best but it works. You will need to build mod_jk, Im not sure if you can find it in the CentOS repositories.
If you just wanna use HTTP, then mod_proxy should do the job. I would suggest to show use the config for apache, also test if tomcat works standalone on HTTP.
|
|
|
12-03-2010, 10:14 AM
|
#11
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep: 
|
@dexznrl: This problem is not difficult to solve if you actually pay attention to the suggestions on this thread. Instead of flailing through trial and error attempts, benefit from research and work that others have already done.
|
|
|
12-03-2010, 04:58 PM
|
#12
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Quote:
That requires Tomcat to run as root. (Which OP may be OK with, but I try to avoid. )
|
Is it not possible to start as root and drop to a lesser account afterwards?
|
|
|
12-08-2010, 09:03 AM
|
#13
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep: 
|
That would be the right way to handle things, but Tomcat (last I checked) has no such ability. AFAIK, it's a single process/daemon that spawns no children - unprivileged or otherwise.
|
|
|
All times are GMT -5. The time now is 08:53 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|