Saturday, March 1, 2008

Accessing domain before resolving nameservers

To access domain before nameservers resolve,

I have a simple automated method for that.

Lets asume that your main domain is domain.xyz and the ip fior shared hosting is 123.123.123.123 on that server, then here is what you do:

- place in the dns of the main domain a new A record like this

*.s1.domain.xyz A 123.123.123.123

if you have more then 1 server then the next is *.s2.domain.xyz etc...

Then create a vhost.conf file in /home/httpd/vhosts/skel/0/conf with this line in it:

ServerAlias @domain_name@.s1.domain.xyz

The @domain_name@ will be automaticly changed in by Plesk to the domainname that you add. So if you add test.com then the vhost.conf file will say test.com.s1.domain.xyz

This then automaticly creates a serveralias of the patern domain.your.server.name for every created domain on the server and because the wildcard is in your dns it will resolve the minute the domain is created (and apache is restarted).

.skel/0 is the default skel. If you use another default skel or clients use there own skel you will need to create the vhost.conf file there also. If you have more then 1 shared ip then you need to add more then 1 A record to the dns, 1 for every shared ip.
=====================================================================================
One more method to do the same


a) Create an Apache Alias to forward all traffic to one specified directory on an already resolving site to another site. For example, create a vhost.conf under yourdomain.com's conf directory, and add to it:

AliasMatch ^/sites/([^/]+)(/(.*))? /usr/local/psa/home/vhosts/$1/httpdocs/$3

So whenever someone accesses yourdomain.com/sites/anotherdomain.com, they'll actually be accessing anotherdomain.com's directory. This has a few obvious security flaws (none too major though), and cgi scripts won't run properly under the suexec wrapper... it's the price you pay .

b) Just add the nameserver that is hosting the domain to your OS' DNS list. That way the request will stay internal, and will return correctly before your ISPs nameservers are updated.

No comments: