Difference between revisions of "MigrationDomainName/En"

From TuxFamilyFAQ
Jump to navigationJump to search
m (→‎Domain registration and setup: using TuxFamily DNS servers is not mandatory)
m (→‎Migrating the old site to the new: remove superfluous / in RedirectMatch directive)
Line 132: Line 132:
  
 
Once the operation completed, you can add a few lines in the .htaccess file in the old web space to ensure a smooth transition. Open the group/project.tuxfamily.org-web/htdocs/.htaccess and add:
 
Once the operation completed, you can add a few lines in the .htaccess file in the old web space to ensure a smooth transition. Open the group/project.tuxfamily.org-web/htdocs/.htaccess and add:
  RedirectMatch 301 (.*) http://project.org/$1
+
  RedirectMatch 301 (.*) http://project.org$1
  
 
On the new web space, you can easily identify files containing occurrences of the old address with grep:
 
On the new web space, you can easily identify files containing occurrences of the old address with grep:

Revision as of 13:28, 5 November 2016


How to change web address from yourproject.tuxfamily.org to yourproject.org ?

If you put your project in TuxFamily, without being sure of his future, chances are you have not previously invested in a domain name and you have therefore chosen to access your site via an address type http://yourprojet.tuxfamily.org/. This document is intended for people willing to change their Web addresses to http://yourproject.org/ (and http://www.yourproject.org/) . It is intended as a supplement to this page:FAQ TuxFamily : DNS

Conceptual information about domain names

Start with some concepts about the domain names, DNS, etc..

TLDs, domains, sub-domains, ...

Let's analyze Web adress example http://project.tuxfamily.org./ :

  • The last "." is not an error: domain names are organized in a hierarchy with top separator "." (is optional);
  • "org" is a "top-level domain" (TLD) and may be national (.fr, .de, .es, ...) or generic (.org, .com, .net, ...);
  • "tuxfamily.org is a domain name;
  • "project" is a subdomain of "tuxfamily.org.

Note that "www" (for World Wide Web) is a subdomain like any other. It also directs of the hostname. The www subdomain is published by default "default" to specify web/HTTP(S) service. But this sub-domain can be used used to designate a particular machine. Thus, simply book project.org to have potentially www.project.org together with irc.project.org, smtp.project.org, sock.project.org, whateveryoulike.projet.org ...

DNS Resolution

What happens when you request access to projet.tuxfamily.org via your browser?

  1. Your browser must first obtain the IP address corresponding to the domain name you provide. We talk about DNS resolution. It will make query to the DNS server. The IP of this server is provided by the system (see /etc/resolv.conf). Typically, but not necessarily, this server is provided by your ISP.
  2. The browser then asks the question "Where is it project.tuxfamily.org?".
  3. The DNS server will probably have no entry about "project.tuxfamily.org", but he knows that the server (DNS registration "NS", see below), which manages the domain "tuxfamily.org" is ns1.staff.tuxfamily.net.
  4. The DNS server then solve ns1.staff.tuxfamily.net to the 213.246.36.38 IP address (this is equivalent to a motion that we detail, but hey, cut it off)
  5. Using recieved IP address, DNS server will contact the DNS server ns1.staff.tuxfamily.net asking: "Where is it project.tuxfamily.org?"
  6. ns1.staff.tuxfamily.net DNS server responds: "It's the: 212.85.158.4"
  7. The DNS server forwards the response and finally, your browser knows how to access project.tuxfamily.org.

DNS Records

Domain name system (DNS) work with records: a domain specific, they involve various records. Some of them are:

  • NS records (Name Service) to associate a domain with DNS servers; that record is very convenient to manage sub-domains yourself via a DNS server managing the hierarchy under one or more specific areas.
  • A records (Address) to associate a domain with IPv4 addresses.
  • AAAA records (Address) to associate a domain with IPv6 addresses.
  • MX records (Mail Exchange) to associate a domain with mail servers.

Domain registration and setup

And now? The purpose of this page is to configure your domain name to delegate name management to both TuxFamily DNS servers. These servers will indicate to the rest of the world where project.org or www.project.org are, what machine it should contact to send an email to someone having an en@project.org address etc.. So we need to reserve a domain name with a registrar and to assign two NS records to ns1.tuxfamily.net and ns2.tuxfamily.net respectively. The first thing to do is go buy the domain name interests you, and for this you need a registrar. You can take the registrar of your choice. Note that:

  • Each registrar has its own methods to help you configure your domain name and this page can never be exhaustive and detailed about purchasing and configuring a domain name registrars in all possible;
  • assigning a domain name is paid and limited in time and domain name costs can vary from 10 euros per year to infinitum;
  • you must provide personal details, complete domain information accessible via WHOIS.
  • using TuxFamily DNS servers is not mandatory, documented here

Reminder: just register project.org not www.project.org.

Example with Gandi

Here we will assume that you will buy the domain project.org at Gandi. This registrar may deal with (among others) the .com, .net, .org, .biz, .info, .name, .be, .fr and .eu. We describe a registration-purchase process here.

  • Go to https://www.gandi.net/domain/buy/, type project.org and press enter
  • If the domain is available, choose a time and corresponding price
  • Subsequently, choose "Manage myself in command areas under my account ...".
  • Further, for "Gandi Services" you can choose between "Quick Buy" and "Advanced". Choose the last:
    • check the "DNS provided by my host"
    • remove the line DNS2
    • Enter ns1.tuxfamily.net as DNS0; IP field leave empty.
    • Enter ns2.tuxfamily.net as DNS1; IP field leave empty.
  • If you chose "Quick Buy" you should go to configuration interface:
    • Sign on gandi.net if necessary
    • Go to the Administration tab
    • Click the domain name
    • The bottom of the page is devoted to technical parameters, in the box "Name Servers", click "Customize".
  • In any case, do not forget to pay.

Configuration on TuxFamily

Now we must make a few steps on TuxFamily:

  • request the domain name that will tell TuxFamily to configure their DNS so that they can provide IP addresses for your domain.
  • request a new web space, in fact, for technical reasons (TuxFamily host uses the HTTP request to determine the corresponding web space), you must make a copy of your old web space to the new one with the name corresponding the new address of your site. Later old webspace can be removed or you can install a redirection.

Go to panel TuxFamily and choose your project. Demander un nouvel espace web

Request a new webspace

In the "Web spaces for <project>" section choose "Create" and let it guide you. As indicated by the warning:

Be careful, if you want create www.domain.tld, you should create a webspace with domain.tld as servername. VHFFS redirect all request from www.domain.tld to domain.tld

...you automatically have the correct DNS configuration for a site accessible via projet.org as www.projet.org. Take this opportunity to reiterate the purpose and the license of your project.

Ask the domain management from TuxFamily

In the "domain names <project>" section choose "Create" and let it guide you. Take this opportunity to reiterate the purpose and the license of your project.

Migrating the old site to the new

Test the new web space before the establishment of a domain name

You can check the configuration of your domain name to the rest of the world with your own DNS client. Here's an example for qelectrotech.org domain:

vous@votre_machine:~$ dig -t any qelectrotech.org @ns1.tuxfamily.net

; <<>> DiG 9.9.5-12.1-Debian <<>> -t any qelectrotech.org @ns1.tuxfamily.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47977
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;qelectrotech.org.              IN      ANY

;; ANSWER SECTION:
qelectrotech.org.       86400   IN      SOA     ns1.tuxfamily.net. blackhole.tuxfamily.net. 2016030301 28800 7200 604800 86400
qelectrotech.org.       86400   IN      A       212.85.158.4
qelectrotech.org.       86400   IN      NS      ns1.tuxfamily.net.
qelectrotech.org.       86400   IN      NS      ns2.tuxfamily.net.
qelectrotech.org.       86400   IN      MX      10 mx1.tuxfamily.net.
qelectrotech.org.       86400   IN      MX      20 mx2.tuxfamily.net.
qelectrotech.org.       86400   IN      AAAA    2a02:2178:1000:201::4

;; Query time: 85 msec
;; SERVER: 212.85.158.9#53(212.85.158.9)
;; WHEN: Fri Apr 01 20:25:47 CEST 2016
;; MSG SIZE  rcvd: 213


If the propagation delay plays tricks on you, you can cheat and test your new site directly injecting IP associated with project.org to the configuration of the DNS resolver on your machine:

  • On Windows : c:\windows\system32\drivers\etc\hosts
  • On Unix : /etc/hosts

Add lines in the form:

<IP of TuxFamily>        <domain name>

Example:

212.85.158.4            project.org
2a02:2178:1000:201::4   project.org

Move / copy the contents of the site

You must now transfer the contents of your old web space to the new. To do that use your SSH access to move the contents of the htdocs folder:

shopt -s dotglob
mv group/project.tuxfamily.org-web/htdocs/* group/project.org-web/htdocs/

If your quota allows, you can copy to make sure everything is functional on the new web space:

shopt -s dotglob
cp -rpf group/project.tuxfamily.org-web/htdocs/* group/project.org-web/htdocs/

Once the operation completed, you can add a few lines in the .htaccess file in the old web space to ensure a smooth transition. Open the group/project.tuxfamily.org-web/htdocs/.htaccess and add:

RedirectMatch 301 (.*) http://project.org$1

On the new web space, you can easily identify files containing occurrences of the old address with grep:

grep -Irl 'project.tuxfamily.org' group/project.org-web/htdocs/*

If you want to automate the replacement, use sed with -i option. Do not forget to change the contents of your database if necessary.

Transfer statistics

# groupe, ancien et nouvel espace web
group=group
old_webarea=project.tuxfamily.org
new_webarea=project.org

# copy statistics files
cp -rpf ${group}/${old_webarea}-web/awstats/*.txt ${group}/${new_webarea}-web/awstats/

# rename statistics files
cd ${group}/${new_webarea}-web/awstats/
for file in $(ls -1 awstats*.${old_webarea}.txt); do
    mv "$file" $(echo "$file" | sed "s/${old_webarea}/${new_webarea}/")
done