1

I'm running an ec2 instance on ubuntu running lamp stack. I configured my httpd.conf file to support wildcard sub-domain but it didn't work.

My httpd.conf file

 NameVirtualHost *

 <VirtualHost *>
    DocumentRoot /www/example
    ServerName example.com
    ServerAlias *.example.com
</VirtualHost>

I tried all possible solutions but they didn't work. Finally I used amazon Route-53 to setup a wildcard DNS to redirect all *.example.com to example.com. My question is,

  1. Is it okay if I use Route-53 instead of httpd.conf file for wildcard Sub-Domain ?
  2. Is there an error in my httpd.conf file ? (Note: I used the same httpd.conf settings with another hosting provider and it worked perfectly there.)

Additional Information :

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server example.com (/etc/apache2/httpd.conf:1)
         port 80 namevhost example.com (/etc/apache2/httpd.conf:1)
         port 80 namevhost ip-xx-xxx-xx-xxx.ec2.internal (/etc/apache2/sites-enabled/000-default:1)
Syntax OK 
Sharan
  • 111
  • 5

1 Answers1

2

There's no "instead of" - for a wildcard domain to function, you need both.

  • Name resolution needs to send clients to the correct host that's going to serve the content
  • Your web server must answer requests for the domains that it's getting sent the requests for.

Since you now have the wildcard DNS in place, and your Apache server should be responding with that virtual host to all requests (yes, it's correct), then it should be functioning.

First, verify that your client system is resolving the correct name; ping an address in the wildcard. This will not have worked immediately after you added the wildcard entry, since DNS (including negative responses) is heavily cached.

If that's hitting the correct server, then you should verify that the correct virtual host is being used for the requests. You might have some other virtual host getting the requests - can you provide us the output from apache2ctl -S?

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • Just now I tried to ping my website (both name and ip address) but its not working. But the website works fine on the browser. – Sharan Jun 05 '12 at 01:29
  • ICMP may be blocked - the important thing is that the IP address displayed when you try to resolve the name is correct. So, are you saying it's working as expected now? – Shane Madden Jun 05 '12 at 01:34