Archive for November, 2010

CPANEL/WHM: How to bulk add DNS zones on the command line

Thursday, November 4th, 2010

I had about 30 domains I need to create basic zone files for and did not want to do it by hand. I found that you could do the following via the command line:


for i in `cat /root/domainlist`; do /scripts/adddns --domain $i --ip xxx.xxx.xxx.xxx; done;

/root/domainlist is a file that contains a domain on each line without the www. and of course replace xxx.xxx.xxx.xxx with the real ip address:

domain1.com
domain2.com
domain3.com

NGINX: How to forward multiple domains to a primary domain

Thursday, November 4th, 2010

I looked all over the interwebs for this and all I could find were articles on redirecting www to non-www or vice versa. Which is essentially the same thing.. but I figured the web deserves an article dedicated to just this.

The first server block sets up the redirects and the second block is what you are redirecting to. Pretty straight forward. Just make sure to /usr/local/nginx/sbin/nginx -t (or where ever the nginx binary is) before you try to restart as you may accidentally enter some funky characters.


server {
    listen 80;
    server_name secondarydomain.com tertiarydomain.com www.secondarydomain.com www.tertiarydomain.com;
    rewrite ^(.*) http://www.primarydomain.com$1 permanent;
}

server {
    listen 80;
    server_name www.primarydomain.com;
    # config for primary domain here
}