[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3015
  • Last Modified:

How to create subdomains and NOT use DNS

Hi,

I would like to be able to create subdomains on our Apache 2 webserver.

I DO NOT want to add these sub domains to our DNS (currently using third party website).

EXAMPLE:

mydomain.com <- All requests go here

sub.mydomain <- All requests go to root document for this subdomain WITHOUT using DNS

Here is my current configuration but only works with DNS etries:


NameVirtualHost 1.2.3.4
<VirtualHost 1.2.3.4>
ServerAdmin webmaster@mydomain.com
DocumentRoot /root/subdir
DirectoryIndex index.html index.htm index.php index.cgi
ServerName sub.mydomain.com
ErrorLog /var/log/httpd/subdir/error_log
CustomLog /var/log/httpd/subdir/access_log custom env=!object
</VirtualHost>

I hope this question makes sense and I hope this is possible.

Thanks,

BB
0
baxleyb
Asked:
baxleyb
1 Solution
 
caterham_wwwCommented:
> I DO NOT want to add these sub domains to our DNS

Then you must add a wildcard DNS entry like

*.example.com. 172800 IN A IP_goes_here

Otherwise the request does not reach your server.
0
 
periwinkleCommented:
caterham_www is correct - in order for a webpage of a subdomain to be resolved, you need both a dns entry that covers that subdomain, and an apache configuration that covers this domain as well.

If you do not want to specify out each subdomain, you need a wildcard entry like he has specified, as well as some form of default virtualhost configuration, that will pick up the subdomains.
0
 
VIkasumitCommented:
HI,

also as you said

I DO NOT want to add these sub domains to our DNS (currently using third party website).
======== Than ofcourse you can add your subdomains entry in some remote DNS server that resolve to your apache. It is not necessary to have DNS server on same server. But the DNS server name you add your subdomians must be one of the nameserver define for that Domain...

i.e. if you domain is hosted on your server with nameserver as ns1.domain.com and ns2.GenericNameserver.com
and ns1.domain.com is on your server but ns2.GenericNameserver.com belongs to some other server of some hosting company. Than just add your sub-domain DNS entry in there server, and put virtual tag in your apache.

DNS server are to resolve the name to IP once it is done either by your server or by remote it doesn't matter to a request they will get your subdomains IP thats all they need

But for simplicity follow what has been said above ...

Though I am interested to know why you need to do that, if you have a subdomain register it in DNS why you don't want will be interesting...

VIkasumit
0
 
baxleybAuthor Commented:
periwinkle,  caterham_www,

Thanks for your posts. We are currently using DNS to resolve sub-domains but would like the flexibility to NOT use DNS to accomplish this.

So if I did use a wildcard then would EVERY sub domain attempt to resolve to one ip address?

What if I had like 5 that should go to different ip addresses? How would that work?

EXAMPLE:

anotherserver.mydomain.com -> 1.2.3.4

anotherserver.mydomain.com -> 1.1.1.1

*.mydomain.com -> 2.2.2.2

anotherserver.mydomain.com -> 3.3.3.3

Thanks,

BB

 
0
 
baxleybAuthor Commented:
Well I found out that I can use a wildcard, but it has been decided to do this at a later time, for now we'll stick with direct to DNS.

caterham_www, thanks for your advice and response.

Best,

BB
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now