Thursday, November 5, 2009

Virtual Host concept in apache configuration and proxy Apache server

The term Virtual Host refers to the practice hosting more than one website in server on one machine. For example in single sever they can maintain multiple website with different host name as www.example1.com and www.example2.com, without requiring the user to know any extra path information.
How to configure virtual host in different scenarios in your http.config file is defined here

++The common basic virtual host setting
# Virtual hosts
NameVirtualHost 192.1.1.1:80

serverName localhost
Document localhost

In the above through IP address and the port number you can set the sever name in localhost and the
Root Document files path to select root path of the site

++Get information about the requests being processed by the server and the
configuration of the server.

Required modules: 1.mod_status (for the server-status handler),
2.mod_info (for the server-info handler)

SetHandler server-status
Order deny,allow
Deny from all
Allow from .localhost


++ Settings for hosting different languages.

Required modules: mod_mime, mod_negotiation
DefaultLanguage and AddLanguage allows you to specify the language of a document. You can then use content negotiation to give a browser a file in a language the user can understand.

DefaultLanguage nl
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo

++If you want to maintain multiple domains/hostnames on your machine

Most configurations use only name-based virtual hosts so the server doesn't need to worry about IP addresses. This is indicated by the asterisks in the directives below.

ServerAdmin webmaster@dummy-host.localhost
DocumentRoot /www/docs/dummy-host.localhost
ServerName dummy-host.localhost
ServerAlias www.dummy-host.localhost
ErrorLog logs/dummy-host.localhost-error_log
CustomLog logs/dummy-host.localhost-access_log common



ServerAdmin webmaster@dummy-host2.localhost
DocumentRoot /www/docs/dummy-host2.localhost
ServerName dummy-host2.localhost
ErrorLog logs/dummy-host2.localhost-error_log
CustomLog logs/dummy-host2.localhost-access_log common




Proxy Apcahe server

An ordinary forward proxy is an intermediate server that sits between the client and the origin server. In order to get content from the origin server, the client sends a request to the proxy naming the origin server as the target and the proxy then requests the content from the origin server and returns it to the client. The client must be specially configured to use the forward proxy to access other sites.

Required modules:proxy_module , proxy_http_module , proxy_balancer_module



ServerName dummy-host.localhost
ErrorLog logs/dummy-host.localhost-error_log

ProxyRequests Off
proxyPreserveHost on


Order deny,allow
Allow from all


ProxyPass / dummy-host
ProxyPassReverse / dummy-host


Order deny,allow
Allow from all


No comments: