Link to home
Start Free TrialLog in
Avatar of rdong
rdong

asked on

How to hide port 8080?

I have apache2.050 and tomcat 5.5.  Apache uses port 80 and tomcat 8080.  Is there a way to hide port 8080?

Or can I map www.mysite.com:8080/mywebapp/  map to
www.mysite.com/mywebapp/ ?

Thanks
Avatar of samri
samri
Flag of Malaysia image

hi rdong,

technically, you could not hide port 8080 as it would be used by tomcat.  By default apache would bind to port 80, and tomcat would be using port 8080.  However, if you wish, you could configure your apache in such a way that it would accept request, then will redirect/proxied/rewite to the tomcat.

the quickest way to do is by using redirect, where you could use

Redirect /mywebapp http://www.mysite.com:8080/mywebapp/

(

Redirect would cause the URL location to change -- which the user would see the URL on the location bar to change to http://www.mysite.com:8080/mywebapp/

Next, you could use mod_rewrite and/or mod_proxy to use ReverseProxy mode to achive your goal:

PAQ: https://www.experts-exchange.com/questions/20319838/Proxy-to-multiple-servers-getting-images-to-work.html
https://www.experts-exchange.com/questions/20319552/Yet-another-proxying-question.html
Avatar of ramazanyich
You can make redirection from apache httpd to tomcat using mod_jk
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk/aphowto.html
use only ajp connector and disable http connector on tomcat
Avatar of rdong
rdong

ASKER

Thank both for your response.  I want to try ramazanyich's suggestion first.

Apache is pretty new to me, so please bear with me...

I use windows xp.

I have tried to configure http.conf without success.

1. How to add  jk2 module to http.conf?
2. The document says to add this line to http.conf
Include /var/tomcat3/conf/jk/mod_jk.conf-aut

Then I actually add this line to http.conf:

Include C:/Program Files/Apache Software Foundation/Tomcat 5.5/conf/jk/mod_jk.conf-auto
I got an error when I restart apache:

"
Include takes one argument, Name of the config file to be included
Note the errors or messages above, and press the <ESC> key to exit."

3. Where do I put workers.properties file.  How to configure it?

Is that possible you can give me step by step?

Thanks you very much



 

Download mod_jk from apache site: http://apache.belnet.be/jakarta/tomcat-connectors/jk/binaries/win32/
copy mod_jk.dll into modules directory of you apache server.
Modify httpd.conf:
--------
LoadModule modules/mod_jk.dll
AddModule mod_jk.c
JkWorkersFile conf/workers.properties
JkLogFile log/mod_jk.log
JkMount /*.jsp worker1
----------

The 'JkMount' tells mod_jk to forward all requests for
JSP's  to the worker named worker1.

Create file workers.properties in conf directory of your Apache server:
---
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=9009
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
------

in your tomcat server.xml find <Connector> element with attribute which has Ajp13Connector inits value.
check the port attribute of that element and modify its value to 9009
Restart both tomcat and apache.


Avatar of rdong

ASKER

Thanks for your help.

I got stuck here.

1. I followed your steps but when I started apache server it complained:

"LoadModule takes two arguments, a module name and the name of a shared object fi
le to load it from"

So I gave it a name jk_module. So the first line becomes
LoadModule jk_module modules/mod_jk.dll
I found that other module names are not working, how do you get the module name in the first place?

2. After the above being taked cared of, I got another error when restarting apache:

"Invalid command 'AddModule', perhaps mis-spelled or defined by a module not included in the server configuration"

What is mod_jk.c? How do you include it in the server configuration?

Could not go further, please shed some light on this. Also I am wondering, if everything works fine,
www.mysite.com/mywebapp/ will be pointing to www.mysite.com:8080/mywebapp?



remove AddModule line.
It is not necessary if LoadModule already exists.
AddModule directive used to load modules in some order if necessary.
Avatar of rdong

ASKER

Thanks,

I got both apache and tomcat restarted successfully. However can you tell me how can I map localhost:8080/mywebapp
to
localhost/mywebapp?

this is my workers.properties file
===========================
port=9009
host=127.0.0.1

# define the worker
[ajp13:localhost:9009]
channel=channel.socket:localhost:9009
group=lb
#
#[uri:/mywebapp/*]

group=lb

[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:

worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=9009
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
========================

This is server.xml in tomcat
=====================
................
  <Connector port="9009"
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />
........
========================

do I need to change anything in jk2.properties in tomcat?

Thanks so much
ASKER CERTIFIED SOLUTION
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial