Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
share|improve this question
add comment

1 Answer 1

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?

share|improve this answer
    
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 5 '12 at 1: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 5 '12 at 1:34
    
Oic... Anyways the default web-address works but the wildcard subdomain address doesn't work. It shows "Ping request could not find host" –  Sharan Jun 5 '12 at 1:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.