apache http server

Apache virtual host and mod_proxy configuration quick start

Virtual host in apache is a term to point to server running more than one web sites on it. Apache Virtual host features support both ip-based and name based virtual host.

  • IP-based: is for config multi web sites run on difference interface and port
  • Name-based: is using diffence name to recognize the host. It allow multi virtual host using same ip and port.

In this port i just guide how  to configure name based virtual host and mod_proxy. Below is example of part of httpd.conf config file to use apache as proxy route difference domain to right machine that host application.

NameVirtualHost *:80 
<VirtualHost *:80>
ServerName api.devjav.com
ProxyPass / http://ip_or_hostname/api/
ProxyPassReverse / http://ip_or_hostname/api/
</VirtualHost>

<VirtualHost *:80>
ServerName api2.devjav.com
ProxyPass / http://other_ip_or_hostname:port/api/
ProxyPassReverse / http://other_ip_or_hostname:port/api2/
</VirtualHost>

In this example i want to route to specific server that host application base on the domain that user access. If users access api.devjav.com it will route to one server, if they access using api2.devjav.com it route to other.
We can use this as option to running multi instance of whitelabel application.

Leave a Reply