Click here to Skip to main content
15,879,474 members
Articles / Containers / Virtual Machine
Tip/Trick

Apache vhosts on Windows Azure platform

Rate me:
Please Sign up or sign in to vote.
4.83/5 (3 votes)
19 Dec 2013CPOL2 min read 22.1K   1   3
Configuring Apache vhosts to access subdomain from outside of local network on Microsoft Windows Azure platform

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.  

Image 1

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.   

  • 12/19/2013 - Update 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems / Hardware Administrator Cro-bit Ltd.
Croatia Croatia
I'm a PC Technician by profession, currently studying computing at Univeristy of Split, FESB
If you wish to contact me you may do so by LinkedIn on http://www.linkedin.com/in/marincokaric/

Comments and Discussions

 
QuestionI Didn't Need To Do All This Pin
Maciel Silva31-Aug-21 9:57
Maciel Silva31-Aug-21 9:57 
QuestionDNS Pin
Member 1033576614-Oct-13 9:21
Member 1033576614-Oct-13 9:21 
AnswerRe: DNS Pin
Marin Cokarić19-Dec-13 7:23
Marin Cokarić19-Dec-13 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.