On Sun, Mar 9, 2014 at 5:05 PM, Neven Cvetkovic <[email protected]>wrote:
> Ahmed, > > On Sun, Mar 9, 2014 at 10:14 AM, Ahmed Dalatony <[email protected] > >wrote: > > > hello, > > > can you help me little more with example or simpler doc > > i'm new to tomcat config > > and i don't understand virtual host > > > > thank you > > > > Ultimately, if you don't want to show the port number to the end user, the > serving process needs to bind to port 80. > > You mentioned few Tomcat processes, bound to ports 7777, 8888, 9999, each > serving few applications. > > So, here are few alternatives to achieve what you want: > > ALTERNATIVE_0 > - Don't do anything. Each Tomcat instance runs on it's own port number. > - Doesn't achieve what you want :) > > ALTERNATIVE_1 > - Host all applications on a single Tomcat instance. Bind Tomcat to port 80 > (if linux environment remember port 80 is privileged port, so you have to > configure your Tomcat accordingly.) Register all domains to the same IP > address. > - You can use Tomcat virtual hosting to register different domains to > specific applications. > - Downside of this approach is that all applications are sharing the same > JVM (Tomcat) instance. Spike in one application can bring all other > applications down. > > ALTERNATIVE_2 > - Have multiple network interfaces (IP addresses) available. Bind each > Tomcat instance to one of the IP addresses. Register each domain to its own > IP address. > - This approach is better than ALTERNATIVE_1 when it comes to isolation of > the processes in their own execution environments. > - This approach utilizes many IP addresses, that are usually scarce and not > easily justified for numerous applications. > > ALTERNATIVE_3 > - Most common approach I've seen around. > - Similar to approach you are currently taking (ALTERNATIVE_0), with a help > of external web server that will act as a (reverse) proxy. Typically, I > would use Apache Httpd server, but you can use other web servers, e.g. IIS > on Windows platform, or nginx. > - In this case Apache (or other webserver) would bind to port 80, and based > on the requested URL (or host) would point to a specific application > (hosted on specific Tomcat on certain port, e.g. 7777, 8888, 9999, etc...) > - If you would like to achieve that different hosts point to different > applications, register all domains with the same IP address in DNS, and > configure virtual hosting on the webserver. > > > Thus, if you run multiple instances of Tomcat - alone, virtual hosting will > not help you , since only one process can bind to a single IP address to > one port (e.g. port 80). So, either put everything to the same Tomcat > ("yuck"), or bind each tomcat to port 80 on separate IP addresses, or have > an external web server routing requests to your multiple Tomcat instances. > My preference is the later approach. > > Here are some questions you want to answer before choosing the alternative: > - What is the environment that you run on (windows, linux, etc.)? > - What are you requirements? > - How many applications do you have? How many instances do you plan to run, > on the same machine, on the entire platform? > - What are the application usage patterns? (how many users do you plan to > serve, spikes, etc..) > - What are the service level agreements you have with your customers? > - etc... > > > Configuring webserver to route requests to Tomcat instances is pretty > straight forward, and you have a choice of HTTP or AJP protocols and > depends on the choice of your webserver (Apache HTTPD, IIS, nginx, etc.) > > Hope that helps. > > Cheers! > Neven > thanks Dan & Neven i think 3rd alternative is my way to go i'll start searching about it and see what i get
