Mapping domain

Simplest solution is to edit your /etc/hosts file. The more elegant solution is to run your own DNS.
 
Thank SirDice for reply

Let's me explain more: I have built successfully tomcat server with IP is 192.168.1.225 and I also have DNS server that configured domain name: abc.com to IP 192.168.1.225.

Whenever I need to access to tomcat server using browser, I have to use the port like http://192.168.1.225:8180 or http://abc.com:8180

Now, I need to map that when I access to tomcat server, instead of give port after address, I just access to http://tomcat.abc.com

Please help me to solve it.

Thank so much.
p/s My DNS server is using djbdns.
 
you can use apache with mod_jk in front of tomcat and setting your apache config / vhost config with .htaccess using mod_rewrite on vhost document root but it's not easy. You must be a little bit tricky.
 
Hello,

This would be possible if tomcat.abc.com is for example IP: 10.0.0.1 and abc.com IP: 10.0.0.2.

Then with firewall you can make rule for example: requests from everyone everywhere (or some private list) to 10.0.0.1 port 80, to be redirected to 10.0.0.2 port 8180.
 
quintessence said:
This would be possible if tomcat.abc.com is for example IP: 10.0.0.1 and abc.com IP: 10.0.0.2.

Then with firewall you can make rule for example: requests from everyone everywhere (or some private list) to 10.0.0.1 port 80, to be redirected to 10.0.0.2 port 8180.
That's not possible.

But if tomcat is also bound to 127.0.0.1 you can redirect it to there.
 
quintessence said:
Which part is not possible ?

Redirecting 10.0.0.1:80 to 10.0.0.2:8180 when both addresses are on the same interface.
 
bbzz said:
Not on same interface; same host.

Multiple interfaces on the same network subnet is not a good idea ;)

But, as I said, you can redirect 10.0.0.1:80 to 127.0.0.1:8180. If tomcat is bound to * (all addresses) then this should work.
 
SirDice said:
Redirecting 10.0.0.1:80 to 10.0.0.2:8180 when both addresses are on the same interface.

Hello,

Well, actually it works.

Code:
rdr pass on lo proto tcp from any to 10.0.0.1 port 80 -> 10.0.0.2 port 8180

How correct is is other topic, IP addresses were just an example :)
 
Hi,

I'm not 100% sure what you need to achieve, if you need to have tomcat listen on port 80 instead of port 8080 you can change this in tomcat's server.xml config file.

If you need to do anything more elaborate you can do it via mod_jk and Apache HTTPD as mentioned by biru. That would allow you to have the server use apache NameVirtualHost, add SSL etc. That requires an entry like this in the tomcat config:

Code:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

and in the Apache HTTPD config something like:

Code:
# Load mod_jk module
LoadModule    jk_module  libexec/apache22/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
#AddModule     mod_jk.c
# Where to find workers.properties
JkWorkersFile /tomcat/conf/workers.properties
# Where to put jk shared memory
JkShmFile     /var/log/httpd/mod_jk.shm
# Where to put jk logs
JkLogFile     /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount  /* ajp13

tomcat/conf/workers.properties needs to exist, but if you don't have an existing file I think you can use a generic one, i.e. search for an example on google.

cheers Andy.
 
Back
Top