Once you have a primary domain up, and you add the DA module, for those of you actively developing sites with DA, how do you lock down your domains/subdomains until they are ready for prime-time? I have contemplated several ways (htaccess etc) but I'm curious how people around here are doing it?

Comments

agentrickard’s picture

We use Domain Alias. Register the development server, and alias the real boxes. We also do a lot of shared work via SVN, which involves everyone having their own code checkout in the pattern:

PROJECT.USERNAME.HOST

So we alias PROJECT.*.HOST to the registered domain(s). However, this can cause an issue where links from PROJECT.ME.HOST are sent to the wrong domain. So I have the following custom code.

This goes at the bottom of settings.php, before we load Domain Access:

/**
 * Special handling for SVN to keep the root domain on a sandbox.
 */
$conf = array();
$conf['domain_svn'] = 0;
if (substr_count($_SERVER['HTTP_HOST'], SERVERNAME) > 0) { // Put your SERVERNAME here.
  $_path = array_slice(array_reverse(explode('.', $_SERVER['HTTP_HOST'])), 0, 5); // Our HOSTS are 5 elements long.
  $conf['domain_root'] = implode('.', array_reverse($_path));
  $conf['domain_svn'] = 1;
}

Then this code goes in a custom module:

/**
 * Implement hook_domainload().
 */
function custom_domainload(&$domain) {
  $continue = (bool) variable_get('domain_svn', 0);
  if (!$continue) {
    return;
  }
  // Pick up the changes from settings.php
  $root = variable_get('domain_root', '');
  $_root = explode('.', $root);
  $name = $_root[1];
  // Swap out the recorded subdomains with user-specific ones.
  $subdomain = $domain['subdomain'];
  $_sub = array_reverse(explode('.', $subdomain));
  $_sub[3] = $name; // In our case, element 3 is always the USERNAME; your setup may be different.
  $domain['subdomain'] = implode('.', array_reverse($_sub));
}

You can leave this code in place when you go live.

When the project goes live, we switch out the production domains into an alias. You could also set up separate tables in the db if you like. Something like this:

/**
 * Special handling for Domain table prefixing.
 */
$db_prefix = array();
$conf['domain_svn'] = 0;
if (substr_count($_SERVER['HTTP_HOST'], SERVERNAME) > 0) { // Put your SERVERNAME here.
  $db_prefix['domain'] = 'staging_';
  $db_prefix['domain_alias'] = 'staging_';
}

Then you would need a {staging_domain} and {staging_domain_alias} table, created through SQL admin. You can also set up prefixing per user, which we had to do for D5, since there is no Domain Alias.

jmather’s picture

Thanks, very interesting technique. Does that mean you have multiple developers working off of a development machine or off of the aliased live machine which you then go live with using another alias?

I suppose I was hoping to get some info on using some kind of module like http://drupal.org/project/securesite to lockout spiders and unwanted visitors, perhaps this technique solves this problem as well.

The secure site module might work with DA, but I haven't tried...

Thx.

agentrickard’s picture

Oh, well, you can set all your domains (except primary) to 'inactive' and then only admins can access them.

Otherwise, I would register an IP (not a DNS) as the domain, and then secure the IP.

And, yes, we have multiple developers on a shared server. One database with infinite SVN sources.

agentrickard’s picture

Status: Active » Closed (fixed)
jmather’s picture

One quick question on this, you said that when a domain is 'inactive' then only admins can access them. I disabled one of my (non-primary) domains and then logged in as admin and was not able to view the inactive domain, most likely because it is not a subdomain and I don't have the shared sign-on module running, would the shared sign-on module allow this?

jmather’s picture

Status: Closed (fixed) » Active
jmather’s picture

I tested my above scenario with the shared sign on module, I got the shared sign on to work, but when logging in as admin to the master domain with the other domain inactive I could not browse to the inactive domain. Not sure why that is the case but I'm looking in the shared sign-on module to see, if anyone has any hints....

Thanks.

agentrickard’s picture

Nothing to do with Shared Sign-On. Its based on the 'administer domains' permission.

agentrickard’s picture

Status: Active » Closed (fixed)
agentrickard’s picture

Title: How do you manage your in development domains/subdomains » Document how you manage your in development domains/subdomains
Priority: Normal » Major
Status: Closed (fixed) » Active
Issue tags: +handbook

Needs to be added to online docs.

croryx’s picture

I added an edited version of your response in #1 to http://drupal.org/node/1096988.

agentrickard’s picture

Nice. I think it's a bit confusing and might need its own page. I made some edits.

dqd’s picture

Issue summary: View changes
Status: Active » Fixed

Sounds like fixed.

Apart from that: I'll close this issue due to inactivity for 13 years and even if I would move it to the next nearest core version which is 7, there is upcoming EOL of Drupal 7 in January 2025. While the project's version for Drupal 7 will surely keep providing support for security issues and website breaking bug fixes for Drupal 7, we should try to minimize the open issues for Drupal 7 in the queue as much as possible. A big thanks around for the report and all the efforts in here. Feel free to re-open if you can provide a fix or found an additional related problem which increases the issue priority.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.