Introduction
I am no Windows expert when it comes to hosting, using Linux for most of my servers, so I got stuck on basic thing, configuration of Virtual hosts on Windows Server 2012. Server is hosted on Windows Azure platform.
After I got stuck and with no idea how to proceed I opened a question on StackOverflow
http://stackoverflow.com/questions/18591806/configurating-apache-vhosts-to-access-domain-from-outside-of-local-network/18592557?noredirect=1#18592557
I already answered there how to fix it but I decided to make a article on CodeProject to make it more clear.
How to?
First of all I uncommented lines in
httpd.conf (C:\xampp\apache\conf\httpd.conf)
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include "conf/extra/httpd-vhosts.conf"
and changed the following line
Listen 255.255.255.254:80
where 255.255.255.254 is VM Internal Private Address that can also be obtained on VM Dashboard at manage.windowsazure.com.
Check the attached picture for preview.
I also uncommented line 19 in vhost file httpd-vhosts.conf (C:\xampp\apache\conf\extra\httpd-vhosts.conf)
NameVirtualHost *:80
at the end of vhost file (httpd-vhosts.conf) I added
<VirtualHost landing.mydomain.com:80>
DocumentRoot "C:/xampp/htdocs/landing"
ServerName landing.mydomain.com
ServerAlias landing.mydomain.com
</VirtualHost>
Where landing.mydomain.com in ServerName and Server Alias is my subdomain that I redirected on Domain Control panel to Virtual Machine (VM) Public Virtual IP 255.255.255.255 by creating new A record landing.
VM Public Virtual IP can be found on VM Dashboard.
After we saved vhost configuration file we proceed to edit server host file
C:\Windows\System32\Drivers\etc\host
Edit it using Notepad or Notepad++ but as Administrator (if you aren't already a Administrator of your machine) and add the following line
255.255.255.254 landing.mydomain.com
where 255.255.255.254 is VM Internal Private Address and landing.mydomain.com is Virtual host you added inside vhost file.
<VirtualHost landing.mydomain.com:80>
Save and restart Apache.
That's all folks :)
Update
I forgot to mention, don't forget to configure Windows Server Firewall (allow on ports 80 and 443, tcp incoming traffic) as well as endpoints (tcp 80 and 443) on Windows Azure platform.
Other articles that may be useful
History
- 09/03/2013 - First published.