Archive for Apache 2

Solaris 10 DNS Server for LAN

I finally got a DNS server up and running for my computers. Thanks to http://www.logiqwest.com/dataCenter/Demos/RunBooks/DNS/DNSsetup.html
with a great little script that turns your hosts file into DNS entries for BIND.
Basically it came down to:
Editing the /etc/hosts file to have all the records I wanted
Create /var/named directory
Place the h2n script in the /var/named directory
Execute the script with the following options:
./h2n -d mydomain.home -n 192.168.1 -u email@mydomain.home
Edit the resulting db.mydomain file to contain a CNAME to work nicely with my apache config
* CNAME sunfire
Download the named.root file from ftp://ftp.rs.internic.net/
Copy it into the /var/named directory and change the name to db.cache
cp named.conf /etc
Make sure /etc/nsswitch.conf has the following line:
hosts: files dns
Create or Edit /etc/defaultdomain to contain the domain name, ie, “mydomain.home”
Set the domain name
# domainname `cat /etc/defaultdomain`
Edit /etc/resolv.conf to contain:
# these entries should be after the real world nameserver entries
domain mydomain.home # the domain just made
nameserver 192.168.1.110 # the IP of the DNS server
Check if the DNS server is running:
svcs -a | grep dns
If it isn’t, start it with:
svcadm enable /network/dns/server
Then start the named service:
/usr/sbin/in.named &
“To use DNS, clients need to modify the /etc/resolv.conf, and /etc/nsswitch.conf as above. The /etc/defaultdomain file must also be created and establsihed as above.”
I was able to use the DNS server I just made from a linux PC by just adding the IP of the new DNS server to my /etc/resolv.conf file

Leave a Comment

More on redirects with apache

Okay I got the redirects working finally (correctly), to redirect domain.com to www.domain.com. I tried a simple RedirectMatch but that was directing everything with “sunfire.mydomain.home” to “www.sunfire.mydomain.home”. So “blog.sunfire.mydomain.home” was redirecting to “www.sunfire.mydomain.home”.

Just had to put this in my .htaccess:

RewriteEngine On
#Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^sunfire\.mydomain\.home
RewriteRule ^(.*)$ http://www.sunfire.mydomain.home [R=permanent,L]

Notice I don’t need the +FollowSymlinks in .htaccess because I put that in my httpd.conf

Leave a Comment

Getting redirects working in apache

Been down for a while, reconfiguring apache. I got the automatic domain thing working now so I can make all the subdomains I want and apache will automatically redirect to them.

Of course I managed to screw it up somehow and had some sort of redirect loop going on. I just redid everything and it seems to be working now. I had been playing around with RedirectMatch and different configurations in httpd.conf and think I had some conflicting info somewhere, so resorted to a backup and stepped back through setting up the virtual servers. Used this site http://www.megalinux.net/archives/649.html as my guide.

To make the virtual servers work really nicely and not have to set multiple ones up in apache do it like that site says:
These are the steps from the site but subsituted with what I needed to use.
Step 1: Configure wild-card DNS, so that *.sunfire.mydomain.home is a CNAME to sunfire.mydomain.home

Step 2: Configure apache. Create a new virtualhost section for *.sunfire.mydomain.home, like:

VirtualHost *
ServerAlias *.sunfire.mydomain.home
CustomLog /www/logs/subdomains.sunfire.mydomain.home-access_log combined
ErrorLog /www/logs/subdomains.sunfire.mydomain.home-error_log
VirtualDocumentRoot /www/%0
VirtualScriptAlias /www/%0/cgi-bin/
/VirtualHost

Step 3: Restart apache to activate the new configuration

Step 4: Now, say you need blog.sunfire.mydomain.home, all that is required is to create these two directories
/www/blog.sunfire.mydomain.home/
/www/blog.sunfire.mydomain.home/cgi-bin/

Put the pertinent files in them and you can access them without having to restart apache

To do: Setup a redirect from domain.com to www.subdomain.com.

Leave a Comment