Click here to Skip to main content
15,892,005 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.2K   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 
Hi,

I am sorry I haven't replied here immediately but I do not login here that often.

I knew it wont be possible for you to create such a solution but I was not quite sure so I tested.

I added record in host file
255.255.255.254		test.mydomain.cloudapp.net


and I created new vhost in httpd-vhosts.conf

<VirtualHost test.mydomain.cloudapp.net:80>
DocumentRoot "C:\xampp\htdocs\test"
ServerName test.mydomain.cloudapp.net
ServerAlias test.mydomain.cloudapp.net
</VirtualHost>


Restarted Apache and voila from localhost as I expected it works but from outside the network not. Meaning this solution can work only for You on Your own machine (server).

To obtain DNS you should buy it from DNS provider such as name.com, I buy all my domains from there for years now. Here's a voucher code for free whois PRIVACYPLEASE Wink | ;)

This is a tutorial on name.com on how to create A records

http://support.name.com/entries/21479548-How-do-I-create-A-records-to-point-to-the-IP-of-my-web-host-[^]

Just to be sure I Googled few articles, here is one of them
http://stackoverflow.com/questions/18765900/subdomain-on-azure-vm-iis-x-y-cloudapp-net[^]

If you are still not sure how to configure DNS or have any problems You can contact me by LinkedIn http://www.linkedin.com/in/marincokaric[^] or just add me on Skype marin.cokaric and I will try to help You with what I know Wink | ;)

Best regards,
Marin Cokarić

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.