logo
  • Home
  • About Us

Category Archives: Apache

Apache Web Server – How Name based Virtual host works

The ServerName and ServerAlias is more like a company’s internal phone list. Your webserver is the switchboard; it will accept all incoming connections to the server. Then the client/caller will tell them what name they’re looking for, and it will look in the Apache configuration for how to handle that name. If the name isn’t listed as a ServerName/ServerAlias in the apache configuration, apache will always give them the first VirtualHost listed. Or, if there’s no VirtualHost at all, it will give the same content no matter what hostname is given in the request.

So, step by step for a normal connection:
1.  You type “http://www.example.com” into your browser.
2.  Your computer asks its DNS resolver which IP address it should use when it wants to talk to www.example.com.
3.  Your computer connects to that IP address, and says that it wants to talk to www.example.com (that’s the Host:header in HTTP).
4.  The webserver looks at its configuration to figure out what to do with a request for content from www.example.com.

Any one of the following may happen:

  • www.example.com is listed as a ServerName or ServerAlias for a VirtualHost – if so, then it will use the configuration for that VirtualHost to deliver the content.
  • The server doesn’t have any VirtualHosts at all – if so, then it will use the configuration in its httpd.conf to deliver the content.
  • The server has VirtualHosts but www.example.com isn’t listed in any of them – if so, the first Virtualhost in the list will be used to deliver the content.

<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin [email protected]
ServerName abc.com
ServerAlias example.com
…

Apache Virtual Hosting

There are two types Apache Virtual Hosting

Name Based Virtual Hosting

With the name based virtual hosting you can host several domains/websites on a single machine with a single IP. All domains on that server will be sharing a single IP. It’s easier to configure than IP based virtual hosting, you only need to configure DNS of the domain to map it with its correct IP address and then configure Apache to recognize it with the domain names.
A technical prerequisite needed for name-based virtual hosts is a web browser with HTTP/1.1 support (commonplace today) to include the target hostname in the request. This allows a server hosting multiple sites behind one IP address to deliver the correct site’s content. More specifically it means setting the Host HTTP header.

Name

IP Based Virtual Hosting

With the IP based virtual hosting, you can assign a separate IP for each domain on a single server, these IP’s can be attached to the server with single NIC cards and as well as multiple NICs.

IP

mod_cluster VS mod_jk and mod_proxy

mod_cluster advantages over other httpd-based load balancers mod_jk and mod_proxy

Server-side load balance factor calculation

In contrast with traditional httpd-based load balancers, mod_cluster uses load balance factors calculated and provided by the application servers, rather than computing these in the proxy. Consequently, mod_cluster offers a more robust and accurate set of load metrics than is available from the proxy.

Dynamic configuration of httpd workers

Traditional httpd-based load balancers require explicit configuration of the workers available to a proxy.
Like mod_jk maintain the static worker list in worker.properties but mod-cluster allow dynamic worker list means whenever the user load increases you can add Application server nodes dynamically to balance the load. In mod_cluster, the bulk of the proxy’s configuration resides on the application servers. The set of proxies to which an application server will communicate is determined either by a static list or using dynamic discovery via the advertise mechanism.
The application server relays life-cycle events (e.g. server startup/shutdown) to the proxies allowing them to effectively auto-configure themselves. Notably, the graceful shutdown of a server will not result in a fail-over response by a proxy, as is the case with traditional httpd-based load balancers.

Fine grained web-app lifecycle control

Traditional httpd-based load balancers do not handle web application undeployments particularly well.
From the proxy’s perspective requests to an un-deployed web application are indistinguishable from a request for an non-existent resource, and will result in 404 errors. In mod_cluster, each server forwards any web application context lifecycle events (e.g. web-app deploy/un-deploy) to the proxy informing it to start/stop routing requests for a given context to that server.

mod_cluster advantages over mod_jk

AJP is optional

Unlike mod_jk, mod_cluster does not require AJP. httpd connections to application server nodes can use HTTP, HTTPS, or AJP.

Reload new config changes without restarting Apache

Made changes to the httpd.conf file. How do I reload the new config changes without restarting the Apache 2 web server?

This (USR1) (gracefully) signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they’re not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.

Syntax :-

‪‎#apachectl‬ -k graceful

#/etc/init.d/httpd reload

Like Us

Archives

  • December 2015 (4)
  • October 2015 (12)
  • September 2015 (2)

Categories

  • Apache
  • Info
  • Java
  • JBoss
  • Linux
  • Tips&Tricks
  • About Us