HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=29)
-   -   automatic temporary URL for new sites (http://www.howtoforge.com/forums/showthread.php?t=45838)

apoana 15th May 2010 01:20

automatic temporary URL for new sites
 
This is not heavly tested, but, it's an hack to have an temporary URL for a new site/domain.

Please, ready this:

1) Tested on multi domain setup
2) server hosting sites have the name - in this example: isp01-ww1.myhost.com
3) You need to alter the DNS provider for myhost.com
4) Don't blame me for problens :)
5) All temporary site URL will become yoursite.vsite.isp01-ww1.myhost.com in this example

Let's go:

1) add in you master site (or hosting site) DNS an entry like this:

Code:

*.vsite.isp01-ww1.myhost      Alias (CNAME)    Default      isp01-ww1.myhost.
or

Code:

*.vsite.isp01-ww1.myhost      A    Default      1.2.3.4
2) edit "/usr/local/ispconfig/server/plugins-available/apache2_plugin.inc.php" - in the server where the apache server hosting is running

3) Find in the above script:

PHP Code:

// begin a new ServerAlias line after 30 alias domains
foreach($server_alias as $tmp_alias) {
   if(
$n 30 == 0$server_alias_str .= "\n    ServerAlias ";
   
$server_alias_str .= $tmp_alias;



4) Change to:

PHP Code:

foreach($server_alias as $tmp_alias) {
    if(
$n 30 == 0$server_alias_str .= "\n    ServerAlias ";
    
$daliases explode(" "trim($tmp_alias));
    foreach(
$daliases as $dalias) {
        if (
trim($dalias) != "") {
            
$server_alias_str .=  trim($dalias) . " " trim($dalias) . ".vsite." trim($conf['serverconfig']['server']['hostname']) . " ";
       }
    }


5) Save the file

6) Now, every time you add an new site or alias site, ISPCONFIG generate an apache configuration like:

ServerAlias www.newdomain.com www.newdomain.com.vsite.isp01-ww1.myhost.com

and this allow your client to access an new domain/site in ISPCONFIG without need to change the DNS pointing for the new site/domain. This is done using URL www.newdomain.com.vsite.isp01-ww1.myhost.com, as in case of this example.


TODO;

1) Display in cleint area where to access new site using the temporary URL

radim_h 9th September 2010 21:17

Here is modification from my friend QUIP

Replace:
Code:

foreach($server_alias as $tmp_alias) {
  if($n % 30 == 0) $server_alias_str .= "\n    ServerAlias ";
  $server_alias_str .= $tmp_alias;
}

with
Code:

foreach($server_alias as $tmp_alias) {
    if($n % 30 == 0) $server_alias_str .= "\n    ServerAlias ";
    $daliases = explode(" ", trim($tmp_alias));
    foreach($daliases as $dalias) {
        if (trim($dalias) != "") {
            $wild_dalias = preg_replace('/^www\./', '*.', trim($dalias)) . '.' . trim($conf['serverconfig']['server']['hostname']);
            $short_dalias = preg_replace('/^www\./', '', trim($dalias)) . '.' . trim($conf['serverconfig']['server']['hostname']);
            $server_alias_str .=  trim($dalias) . " " . $wild_dalias . " " . $short_dalias . " ";
      }
    }
}

Then every domain will have bit different type of preview:

domain.tld
will have aliases
domain.tld.servername.serverdomain.tld, *domain.tld.servername.serverdomain.tld

but only when in
Web Sites=>Domain =>Auto-Subdomain "www." or "*." is chosen
it will not work with None

radim_h 10th September 2010 10:46

don't you have any idea how to make that ServerAlias to be in apache config permanently (also with None selected) ?

omig 10th December 2010 19:55

temporary/test URL for any subdomain setting
 
Here is my solution, it works for any subdomain setting. I suggest adding this feature to svn.

Find in the /usr/local/ispconfig/server/plugins-available/apache2_plugin.inc.php script:
Code:

>$tpl->setVar('alias','');
>        }

after that, add:
Code:

//* Add "temporary URL" Server alias like exampletld.server.mydomain.com
$vhost_domain = $tpl->getVar('domain');
$new_site_temporary_url = "\n    ServerAlias " . preg_replace("/\./","",$vhost_domain) . '.' . trim($conf['serverconfig']['server']['hostname']);
$server_alias_str = $tpl->getVar("alias") . $new_site_temporary_url;
$tpl->setVar('alias',$server_alias_str);


felan 24th September 2012 11:29

Been playing around with this solution but I can't really get it to work, where the solution from Radim_h's friend works fine. I am also wondering if this would be possible to set as a checkbox so we can remove this when not needed anymore?

Quote:

Originally Posted by omig (Post 246326)
Here is my solution, it works for any subdomain setting. I suggest adding this feature to svn.

Find in the /usr/local/ispconfig/server/plugins-available/apache2_plugin.inc.php script:
Code:

>$tpl->setVar('alias','');
>        }

after that, add:
Code:

//* Add "temporary URL" Server alias like exampletld.server.mydomain.com
$vhost_domain = $tpl->getVar('domain');
$new_site_temporary_url = "\n    ServerAlias " . preg_replace("/\./","",$vhost_domain) . '.' . trim($conf['serverconfig']['server']['hostname']);
$server_alias_str = $tpl->getVar("alias") . $new_site_temporary_url;
$tpl->setVar('alias',$server_alias_str);



Croydon 24th September 2012 13:24

In current svn (upcoming 3.0.5 release) there is a feature for this.
You can configure a server alias for new vhost in the server config for each server.
It will be under system -> server config -> {choose server} -> tab "web" -> auto alias.

felan 24th September 2012 13:26

Wonderful, thanks :D

Outbreaker 31st May 2013 02:02

A little bit more infos about this option in ISPConfig 3.0.5 would be nice.
1. What exactly do i need to entry in this field?
2. Is the alias only create for new website or also for the existing ones?
3. If i use the Placeholder [website_domain] or [website_id] will the alias also be update if the website domain name or website id changes?

felan 31st May 2013 09:23

Hi Outbreaker.

If you go in to Server -> Server Config -> Your server -> WEB, you can see the URL and edit it in Website auto alias. Personally I've set it to [website_domain].testserver.designfyn.dk. That means the URL will be domain.tdl.testserver.designfyn.dk

Hope it helps

Outbreaker 31st May 2013 12:59

If i do that, do i have to also add this A record in the "DNS Zone"
Hostname / IP-Address
* / 26.153.48.62
Or should this works without this "DNS Zone" entry?


All times are GMT +2. The time now is 14:04.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.