NGPriest: DNS Work

Ξ November 10th, 2008 | → 0 Comments | ∇ Author: NGPriest |

This usually means adding a “*” hostname record pointing at your webserver in your DNS configuration tool.

In Bind you need to set up a wildcard entry to catch anything that a misguided user or bad typist might enter in front of your domain name. Just like when searching or using regular expressions you use an asterisk (or splat) to match any number of any characters the same thing applies in Bind. So at the end of my zone DB file (/var/named/photomatt.net.db) I added the following line:

*.photomatt.net. 14400 IN A 64.246.62.114

Note the period after my domain. The IP is my shared IP address. That’s all you need, now restart bind. (For me /etc/init.d/named restart.)

Now you need to set up Apache to respond to requests on any hostname under photomatt.net. Before I just used the convinence of having a dedicated IP for this site and having the redirect VirtualHost entry occur first in my httpd.conf file. That works, but I have a better solution now. So we want to tell Apache to respond to any request on any subdomain (that does not already have an existing subdomain entry) and redirect it to photomatt.net. Here’s what I have:


DocumentRoot /home/photomat/public_html
BytesLog domlogs/photomatt.net-bytes_log
ServerAlias *.photomatt.net
ServerName www.photomatt.net
CustomLog domlogs/photomatt.net combined
RedirectMatch 301 (.*) http://photomatt.net$1

The two magic lines are the ServerAlias directive which is self explanitory and the RedirectMatch line which redirects all requests to photomatt.net in a permanent manner.

There is a catch though. The redirecting VirtualHost entry must come after any valid subdomain VirtualHost entries you may have, for example I have one for cvs.photomatt.net and I had to move that entry up in the httpd.conf because Apache just moves down that file and uses the first one it comes to that matches, so the wildcard should be last.

That is it, I’m open to comments and suggestions for improvement.

Now i have to get this to work on the Magellan Server or else the project is dead
Anyone want to help?
They need to know how to use

  • Linux
  • Apache
  • PHP
  • MySQL
  • mod_rewrite

 

Comments

Name (required)

Email (required)

Website

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Share your wisdom

RSS

    Welcome to

    NGPriest's Blog


    There are 5,526 posts and 302 comments so far. Feel invited to browse the archives, read the about or comment on the latest post.

    Search:

    • BananaStatio is 23/M/KL, KL, Malaysia
    • ChambyT is 1x/F/Sungai Bakap, Penang, Malaysia
    • chingyi1807 is 1x/F/Malaysia
    • CopyCatty is 1x/M/Hong Kong
    • crazymango is 15/F/Malaysia
    • Eliteratty is ??/M/???
    • HolySprings is 18/M/Sungai Bakap, Penang, Malaysia
    • jaigralia is unknown...
    • Jykur0 is 14/M/Indonesia
    • MakoJr is 1x/M/Singapore
    • NGPriest is 19/M/Brisbane, QLD, Australia
    • PoringCat098 is 1x/F/Malaysia
    • Saphira is 15/F/George Town, Penang, Malaysia
    • shiningthrust is 13/M/Singapore
      shiningthrust is Single
    • sianzxd is 18/M/George Town, Penang, Malaysia
    • Swifty13 is 1x/M/United Kingdom
    • WingzOfChaos is 15/M/Singapore
      Single/Lonely/Depressed

Random stuff!

  • Loved by Some,
    Hated by Many,
    Envied by Most,
    Yet Wanted by Plenty
  • 10% luck
    20% skill
    15% concentrated power of will
    5% pleasure
    50% pain
    100% reason to remember the name!
  • I write your name in my breath on the window, Sit and watch as it fades away
  • Hi honey.
    Guess what I did at work today?
    I wore a bomb.
    A nuclear bomb in a field of flowers.
    I could get lucky.
    Tomorrow I could have a bigger bomb.
    I could kill more people.
    Maybe they'll be innocent people.
    Children, maybe.
  • "You are like a plague, John Crichton,
    and you have ruined my life . . .
    and yet
    I just keep coming back."
  • I'll watch the night turn light blue
    But it's not the same without you
    Because it takes two to whisper quietly
    The silence isn't so bad
    Till I look at my hands and feel sad
    Cause the spaces between my fingers
    Are right where yours fit perfectly

Search