Ashwin Sridhar
Ashwin Sridhar

Reputation: 135

Accessing Web application in tomcat without port numbers

I am trying to have multiple tomcat instances on a Linux server and each instance would have an web application ROOT deployed in it.

While accessing the application, the url is formed in the format : whereas I don't want the end users to remember the ip address or the port of the application.

Since more than one instances would be used in the linux server, defaulting to 80 port ( http ) and 443 ( https ) wouldn't help out.

The idea is to expose the DNS name for the application and looks like Apache HTTP server would help me solve the case. Is the approach right ?

I assume the apache server should be one per linux server vs one per tomcat instance. Could this be confirmed ?

The Apache Tomcat version is 8.5.4 and the plan is to go with the apache http server version 2.4

Upvotes: 0

Views: 1182

Answers (1)

jlumietu
jlumietu

Reputation: 6444

Setting an Apache HTTPD (or any other) as front server is a good approach.

You won't be able to use more than one Apache HTTPD per server, since you don't want to use :port notation in the url's, at least it will not be possible to use standard HTTP/HTTPS ports in more than one HTTPD at once at the same server.

If you plan to use both http and https, you should create at least one virtual host for each of them. There is a limitation on creating virtual hosts for name based virtual host while using SSL 443 port, so if you want to have more than one HTTPS port enabled you will need IP based virtual hosting.

This is the Apache HTTPD 2.4 virtual host documentation.

Then, you could forward requests to each Tomcat using mod_proxy or tomcat connector. I personally choose one or other depending on the current requirements, specially if there is straight correspondence between contexts in Tomcat and Apache HTTPD (in this case I use AJP) or there's the need to rewrite it (mod_rewrite):

httpd://apache.httpd/context1 -> tomcat:XXXX/context1 (ajp tomcat connector)

httpd://apache.httpd/ -> tomcat:XXXX/context2 (mod_rewrite)

httpd://apache.httpd/context3 -> tomcat:XXXX/context4 (mod_rewrite)

Upvotes: 0

Related Questions