Shaun Wingrin
asked on
Tomcat / apache port forwarding... CentOs server
Say,
We've apache listening on port 80 and don't wish to open an additional port.
an instance of Tomcat is listening on port 1234 say.
How do we setup apache to fwd to port 1234 tomcat
I believe httpd.conf needs to be edited.
The application JapserReportsServer, uses tomcat on above port.
Currently there is a url to the apache webserver.
We would need a path off the url to point to apache and hence tomcat port 1234.
PS pls explain function of tomcat versus apache.
We've apache listening on port 80 and don't wish to open an additional port.
an instance of Tomcat is listening on port 1234 say.
How do we setup apache to fwd to port 1234 tomcat
I believe httpd.conf needs to be edited.
The application JapserReportsServer, uses tomcat on above port.
Currently there is a url to the apache webserver.
We would need a path off the url to point to apache and hence tomcat port 1234.
PS pls explain function of tomcat versus apache.
ASKER
Pls see my qu:
"don't wish to open an additional port"
"don't wish to open an additional port"
ASKER
PS pls explain function of tomcat versus apache.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tx TVEDTEM!
What about httpd.conf file? Can this be used?
With: ProxyPass and ProxyPassReverse ?
What about httpd.conf file? Can this be used?
With: ProxyPass and ProxyPassReverse ?
ASKER
My code below in httpd.conf below returns website unknown .... when goto www.abc.xyz.co.za
<VirtualHost *:80>
DocumentRoot /home/jasperreports-server -cp-5.0.0/ apache-tom cat/webapp s/jasperse rver
ServerName www.abc.xyz.co.za
ErrorLog logs/messaging_error_log
CustomLog logs/messaging_access_log common
ProxyPreserveHost On
# ProxyPass / ajp://127.0.0.1:8009/
# ProxyPass / ajp://localhost:8009/
# ProxyPassReverse / ajp://localhost:8009/
# ProxyPass / http://x.x.x.100:991/
# ProxyPassReverse / http://x.x.x.100:991/
ProxyPass / http://127.0.0.1:991/
ProxyPassReverse / http://127.0.0.1:991/
</VirtualHost>
I've tried with this to:
ProxyPass / http://x.x.x.100:991/
ProxyPassReverse / http://x.x.x.100:991/
# ProxyPass / http://127.0.0.1:991/
# ProxyPassReverse / http://127.0.0.1:991/
<VirtualHost *:80>
DocumentRoot /home/jasperreports-server
ServerName www.abc.xyz.co.za
ErrorLog logs/messaging_error_log
CustomLog logs/messaging_access_log common
ProxyPreserveHost On
# ProxyPass / ajp://127.0.0.1:8009/
# ProxyPass / ajp://localhost:8009/
# ProxyPassReverse / ajp://localhost:8009/
# ProxyPass / http://x.x.x.100:991/
# ProxyPassReverse / http://x.x.x.100:991/
ProxyPass / http://127.0.0.1:991/
ProxyPassReverse / http://127.0.0.1:991/
</VirtualHost>
I've tried with this to:
ProxyPass / http://x.x.x.100:991/
ProxyPassReverse / http://x.x.x.100:991/
# ProxyPass / http://127.0.0.1:991/
# ProxyPassReverse / http://127.0.0.1:991/
Yes, you can use ProxyPass (this is mod_proxy) instead. If you don't need any of mod_jk's load balancing etc, this is probably easier and simpler (therefore, better!)
The next step is to establish whether you've reached Tomcat, or not (in other words, whether your IP and port numbers are correct for the Tomcat/Jasper server)
Without knowing exactly what you're seeing (i.e. what 'website unknown' is) it's hard to tell from here. If it's a Tomcat error page then you've done the first bit (forwarding to Tomcat)
Have a look in the Tomcat access and error logs to see if you can see the HTTP requests coming in, and go from there.
If you can't see them, you need to confirm that the IP and ports are correct, and that Tomcat is actually running.
The next step is to establish whether you've reached Tomcat, or not (in other words, whether your IP and port numbers are correct for the Tomcat/Jasper server)
Without knowing exactly what you're seeing (i.e. what 'website unknown' is) it's hard to tell from here. If it's a Tomcat error page then you've done the first bit (forwarding to Tomcat)
Have a look in the Tomcat access and error logs to see if you can see the HTTP requests coming in, and go from there.
If you can't see them, you need to confirm that the IP and ports are correct, and that Tomcat is actually running.
ASKER
Tx. The error is a redirect to my OpenDNS site to say site loading too slow or unavailable....
What is path to logs you refer to?
Is this needed: DocumentRoot /home/jasperreports-server -cp-5.0.0/ apache-tom cat/webapp s/jasperse rver
?
Do I use the local host or pub IP's above ?
# ProxyPass / http://x.x.x.100:991/
# ProxyPassReverse / http://x.x.x.100:991/
ProxyPass / http://127.0.0.1:991/
ProxyPassReverse / http://127.0.0.1:991/
What is path to logs you refer to?
Is this needed: DocumentRoot /home/jasperreports-server
?
Do I use the local host or pub IP's above ?
# ProxyPass / http://x.x.x.100:991/
# ProxyPassReverse / http://x.x.x.100:991/
ProxyPass / http://127.0.0.1:991/
ProxyPassReverse / http://127.0.0.1:991/
You use whatever IP address hosts the Tomcat server, as far as your Apache server is concerned.
This is either a simple or complicated question depending on your environment.
It's going to be hard to go much further without examining your setup, however we can try a couple of things:
Can I take it that your apache server and your tomcat server are in fact the same machine ?
If so, is Tomcat running ?
Is it listening on port 991 ?
netstat -aN
run on the Tomcat server, might tell you something
if tomcat is running on port 991, I would expect this to show up
as might
wget http://x.x.x.x:991/reports
(or whatever the URL is), run from the Apache server
It should return the expected page (HTML), when run from the Apache server, if you have things set up correctly.
DocumentRoot sets the directory from which httpd will serve files.
This is either a simple or complicated question depending on your environment.
It's going to be hard to go much further without examining your setup, however we can try a couple of things:
Can I take it that your apache server and your tomcat server are in fact the same machine ?
If so, is Tomcat running ?
Is it listening on port 991 ?
netstat -aN
run on the Tomcat server, might tell you something
if tomcat is running on port 991, I would expect this to show up
as might
wget http://x.x.x.x:991/reports
(or whatever the URL is), run from the Apache server
It should return the expected page (HTML), when run from the Apache server, if you have things set up correctly.
DocumentRoot sets the directory from which httpd will serve files.
ASKER
tcp 0 0 *:991 *:* LISTEN
On same server...
On same server...
OK, so it's running...
What happens with
wget http://127.0.0.1:991/your_url ?
Remember to check the tomcat access logs, too.
What happens with
wget http://127.0.0.1:991/your_url ?
Remember to check the tomcat access logs, too.
ASKER
[root@messaging jasperserver]# wget http://127.0.0.1:991/tmr.ecommunicate.biz
--2013-01-16 10:32:56-- http://127.0.0.1:991/tmr.ecommunicate.biz
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 10:32:56 ERROR 404: Not Found.
[root@messaging jasperserver]#
--2013-01-16 10:32:56-- http://127.0.0.1:991/tmr.ecommunicate.biz
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 10:32:56 ERROR 404: Not Found.
[root@messaging jasperserver]#
There's nothing at that address... check that tmr.ecommunicate.biz is correct.
Try wget http://127.0.0.1:991 also.
Try wget http://127.0.0.1:991 also.
ASKER
[root@messaging jasperserver]# wget http://127.0.0.1:991
--2013-01-16 10:44:00-- http://127.0.0.1:991/
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[===================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====>] 7,777 --.-K/s in 0s
2013-01-16 10:44:00 (436 MB/s) - `index.html' saved [7777/7777]
[root@messaging jasperserver]#
--2013-01-16 10:44:00-- http://127.0.0.1:991/
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[=====================
2013-01-16 10:44:00 (436 MB/s) - `index.html' saved [7777/7777]
[root@messaging jasperserver]#
ASKER
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="refresh" content="0;url=home.html">
<script language="javascript" type="text/javascript">
window.location="home.html ";
</script>
</head>
<body>
If your browser doesn't automatically go there,
you may want to go to <a href="home.html">the destination</a>
manually.
</body>
</html>
This is index.html
<html>
<head>
<title></title>
<meta http-equiv="refresh" content="0;url=home.html">
<script language="javascript" type="text/javascript">
window.location="home.html
</script>
</head>
<body>
If your browser doesn't automatically go there,
you may want to go to <a href="home.html">the destination</a>
manually.
</body>
</html>
This is index.html
ASKER
I get a different index file if I use the document root above... which refers to Tomcat
You'll need to find a working URL using wget, something that returns the result you are looking for.
Once you have that, you can try it again from outside the system, hitting apache and using the redirect rules. The aim being to make the HTTP request from the outside translate into a tomcat one that works.
Once you have that, you can try it again from outside the system, hitting apache and using the redirect rules. The aim being to make the HTTP request from the outside translate into a tomcat one that works.
ASKER
Pls see and comment:
http://community.jaspersoft.com/wiki/connecting-apache-web-server-tomcat-and-writing-re-direct-rules
What do you suggest please as I'm new to this....
http://community.jaspersoft.com/wiki/connecting-apache-web-server-tomcat-and-writing-re-direct-rules
What do you suggest please as I'm new to this....
Well... I would suggest doing what they suggest. They are using mod_jk.
The problem remains though, what's the URL for jasper reports ? Could it be /jasperserver-pro ?
The problem remains though, what's the URL for jasper reports ? Could it be /jasperserver-pro ?
ASKER
Does this help?
Configure which URLs to manage with Apache
At this point, you'll need to configure Apache to tell it which URLs to process and hand off to Tomcat, and which URLs you want Apache itself to process. For both cases, you'll need to modify /etc/apache2/sites-enabled /000-defau lt. You can add entries right below the "DocumentRoot" line, within the VirtualHost settings. Add the following line under the DocumentRoot entry. This makes it so that you can request JRS via the Apache web server.
JkMount /jasperserver-pro* worker1
Save the file, and restart the apache service (/etc/init.d/apache2 restart). If you now go to http://localhost/jasperserver-pro, you should see the normal JasperReports Server login screen. What you have accomplished so far is to put the Apache web server in front of Tomcat.
What is exact line to add?
Configure which URLs to manage with Apache
At this point, you'll need to configure Apache to tell it which URLs to process and hand off to Tomcat, and which URLs you want Apache itself to process. For both cases, you'll need to modify /etc/apache2/sites-enabled
JkMount /jasperserver-pro* worker1
Save the file, and restart the apache service (/etc/init.d/apache2 restart). If you now go to http://localhost/jasperserver-pro, you should see the normal JasperReports Server login screen. What you have accomplished so far is to put the Apache web server in front of Tomcat.
What is exact line to add?
If you are using mod_jk you can do exactly as they say.
If you do a
wget http://127.0.0.1:991/jasperserver-pro
and it works, then you can probably do it using mod_proxy (as you initially wanted), by using
ProxyPass /jasperserver-pro http://127.0.0.1:991/jasperserver-pro
If the wget works, but the the apache forward doesn't work, look in the tomcat access logs again.
If you do a
wget http://127.0.0.1:991/jasperserver-pro
and it works, then you can probably do it using mod_proxy (as you initially wanted), by using
ProxyPass /jasperserver-pro http://127.0.0.1:991/jasperserver-pro
If the wget works, but the the apache forward doesn't work, look in the tomcat access logs again.
ASKER
Tx.
Trying with mod_proxy
But what is this instruction above as doesn't compile:
JkMount /jasperserver-pro* worker1
PS What are advantages of mod_proxy over mod_jk. Which do you prefer?
Trying with mod_proxy
But what is this instruction above as doesn't compile:
JkMount /jasperserver-pro* worker1
PS What are advantages of mod_proxy over mod_jk. Which do you prefer?
JkMount is mod_jk, so it will only work with mod_jk.
mod_jk allows load balancing and some other clever stuff.
mod_proxy is slightly simpler than mod_jk, so if I was doing it I would start with that.
So,
ProxyPass /jasperserver-pro http://127.0.0.1:991/jasperserver-pro
(+ same for Reverse)
mod_jk allows load balancing and some other clever stuff.
mod_proxy is slightly simpler than mod_jk, so if I was doing it I would start with that.
So,
ProxyPass /jasperserver-pro http://127.0.0.1:991/jasperserver-pro
(+ same for Reverse)
ASKER
Tx! I've used full path: pls see my code - but still no joy.
#A1 Telecoms / Shaunw Code to point to Tomcat/JasperReportsServer
<VirtualHost *:80>
# DocumentRoot /home/shaunw/jasperreports -server-cp -5.0.0
#DocumentRoot JkMount /jasperserver-pro* worker1
ServerName www.tmr.x
ErrorLog logs/messaging_error_log
CustomLog logs/messaging_access_log common
ProxyPreserveHost On
# ProxyPass / ajp://127.0.0.1:8009/
# ProxyPass / ajp://localhost:8009/
# ProxyPassReverse / ajp://localhost:8009/
ProxyPass /home/shaunw/jasperreports -server-cp -5.0.0 http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
ProxyPassReverse /home/shaunw/jasperreports -server-cp -5.0.0 http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
</VirtualHost>
and
[root@messaging jasperreports-server-cp-5. 0.0]# wget http://127.0.0.1:991/www.tmr.x
--2013-01-16 12:22:51-- http://127.0.0.1:991/www.tmr.x
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:22:51 ERROR 404: Not Found.
[root@messaging jasperreports-server-cp-5. 0.0]#
I can't find the log entries - pls direct me,...
#A1 Telecoms / Shaunw Code to point to Tomcat/JasperReportsServer
<VirtualHost *:80>
# DocumentRoot /home/shaunw/jasperreports
#DocumentRoot JkMount /jasperserver-pro* worker1
ServerName www.tmr.x
ErrorLog logs/messaging_error_log
CustomLog logs/messaging_access_log common
ProxyPreserveHost On
# ProxyPass / ajp://127.0.0.1:8009/
# ProxyPass / ajp://localhost:8009/
# ProxyPassReverse / ajp://localhost:8009/
ProxyPass /home/shaunw/jasperreports
ProxyPassReverse /home/shaunw/jasperreports
</VirtualHost>
and
[root@messaging jasperreports-server-cp-5.
--2013-01-16 12:22:51-- http://127.0.0.1:991/www.tmr.x
Connecting to 127.0.0.1:991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:22:51 ERROR 404: Not Found.
[root@messaging jasperreports-server-cp-5.
I can't find the log entries - pls direct me,...
ASKER
other than:
[root@messaging jasperreports-server-cp-5. 0.0]# cd apache-tomcat/logs/
[root@messaging logs]# ls
catalina.2013-01-13.log catalina.out host-manager.2013-01-13.lo g localhost.2013-01-13.log localhost.2013-01-15.log manager.2013-01-13.log
[root@messaging logs]#
and nothing for today
[root@messaging jasperreports-server-cp-5.
[root@messaging logs]# ls
catalina.2013-01-13.log catalina.out host-manager.2013-01-13.lo
[root@messaging logs]#
and nothing for today
First things first.
Are you sure that
http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
Is the correct URL ?
If it is, you should be able to do
wget http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
and see the desired result (whatever that is).
If you can answer that question, we'll move on to the tomcat logs and apache.
Are you sure that
http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
Is the correct URL ?
If it is, you should be able to do
wget http://127.0.0.1:991/home/shaunw/jasperreports-server-cp-5.0.0
and see the desired result (whatever that is).
If you can answer that question, we'll move on to the tomcat logs and apache.
ASKER
/home/shaunw/jasperreports -server-cp -5.0.0 is installation directory.
This is results:
[root@messaging logs]# wget http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
--2013-01-16 12:53:30-- http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:53:30 ERROR 404: Not Found.
[root@messaging logs]# wget http://127.0.0.1:18991/
--2013-01-16 12:53:36-- http://127.0.0.1:18991/
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[===================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====>] 7,777 --.-K/s in 0s
2013-01-16 12:53:36 (494 MB/s) - `index.html' saved [7777/7777]
[root@messaging logs]#
This is results:
[root@messaging logs]# wget http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
--2013-01-16 12:53:30-- http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:53:30 ERROR 404: Not Found.
[root@messaging logs]# wget http://127.0.0.1:18991/
--2013-01-16 12:53:36-- http://127.0.0.1:18991/
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[=====================
2013-01-16 12:53:36 (494 MB/s) - `index.html' saved [7777/7777]
[root@messaging logs]#
ASKER
PS if I ssh into server and create a tunnel I can connect to JRS with
http://127.0.0.1:991/jasperserver/login.html
http://127.0.0.1:991/jasperserver/login.html
ASKER
NB: I was hiding on EE 18991 as 991 and pls dont' be alarmed by below 18991 and not 991 port
/home/shaunw/jasperreports -server-cp -5.0.0 is installation directory.
This is results:
[root@messaging logs]# wget http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
--2013-01-16 12:53:30-- http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:53:30 ERROR 404: Not Found.
[root@messaging logs]# wget http://127.0.0.1:18991/
--2013-01-16 12:53:36-- http://127.0.0.1:18991/
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[===================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====>] 7,777 --.-K/s in 0s
2013-01-16 12:53:36 (494 MB/s) - `index.html' saved [7777/7777]
[root@messaging logs]#
/home/shaunw/jasperreports
This is results:
[root@messaging logs]# wget http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
--2013-01-16 12:53:30-- http://127.0.0.1:18991/home/shaunw/jasperreports-server-cp-5.0.0
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-01-16 12:53:30 ERROR 404: Not Found.
[root@messaging logs]# wget http://127.0.0.1:18991/
--2013-01-16 12:53:36-- http://127.0.0.1:18991/
Connecting to 127.0.0.1:18991... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7777 (7.6K) [text/html]
Saving to: `index.html'
100%[=====================
2013-01-16 12:53:36 (494 MB/s) - `index.html' saved [7777/7777]
[root@messaging logs]#
OK, then if
http://127.0.0.1:991/jasperserver/login.html
is the jasper reports login URL, then I would imagine
ProxyPass /jasperserver http://127.0.0.1:991/jasperserver
might do the trick
http://127.0.0.1:991/jasperserver/login.html
is the jasper reports login URL, then I would imagine
ProxyPass /jasperserver http://127.0.0.1:991/jasperserver
might do the trick
ASKER
ASKER
Say what can we do pls...?
Has the port number suddenly changed ??!
Anyway, from you log file it would appear that..
http://127.0.0.1:18991/jasperserver/
is the correct Jasper URL as far as apache is concerned.
This is the URL that apache sends to tomcat, and the location of jasper reports.
To be absolutely clear.
Your browser sends requests to Apache on port 80
Apache then sends these on to Tomcat, IF the ProxyPass rule is met.
That is, the ProxyPass rule says:
"If the request URL starts with 'jasperserver', then I'm going to send it to port 18991, with the name 'jasperserver'"
I am going to guess that
www.tmr.ecommunicate.co.za
is the address of your website
So that being the case if you have
ProxyPass /jasperserver http://127.0.0.1:18991/jasperserver
in your Apache file then you should be able to get to Jasper reports from a browser using
http://www.tmr.ecommunicate.co.za/jasperserver/
Doing something like
wget http://127.0.0.1:18991/www.tmr.ecommunicate.co.za
from the Apache server makes no sense.
www.tmr.ecommunicate.co.za is only meaningful as a way of reaching Apache in the first place.
I'm going to leave that with you now. Good luck !
Anyway, from you log file it would appear that..
http://127.0.0.1:18991/jasperserver/
is the correct Jasper URL as far as apache is concerned.
This is the URL that apache sends to tomcat, and the location of jasper reports.
To be absolutely clear.
Your browser sends requests to Apache on port 80
Apache then sends these on to Tomcat, IF the ProxyPass rule is met.
That is, the ProxyPass rule says:
"If the request URL starts with 'jasperserver', then I'm going to send it to port 18991, with the name 'jasperserver'"
I am going to guess that
www.tmr.ecommunicate.co.za
is the address of your website
So that being the case if you have
ProxyPass /jasperserver http://127.0.0.1:18991/jasperserver
in your Apache file then you should be able to get to Jasper reports from a browser using
http://www.tmr.ecommunicate.co.za/jasperserver/
Doing something like
wget http://127.0.0.1:18991/www.tmr.ecommunicate.co.za
from the Apache server makes no sense.
www.tmr.ecommunicate.co.za is only meaningful as a way of reaching Apache in the first place.
I'm going to leave that with you now. Good luck !
ASKER
Looking to close this Q soon - still working on this issue. Thank you for your patience.
ASKER
The firewall had to be opened for the port...
For example
www.example.com //for apache
www.example.com:1234 //for tomcat