Koozali.org: home of the SME Server

Wildcard Subdomains

Offline calisun

  • *
  • 601
  • +0/-0
Wildcard Subdomains
« on: December 14, 2011, 10:47:16 PM »
I have changed a domain registrar company and I am having problems with my subdomins.

The previous registrar, in their domain management panel, I was able to enter:
A record:  sample-domain.com  = ###.###.###.###
A record: *.sample-domain.com = ###.###.###.###

so I would get all wildcard subdomain calls directed to my sample-domain.com without any issues.

Now I have switched to GoDaddy and in their domain management panel I can only enter:
A record: @ = ###.###.###.###
A record: *  = ###.###.###.###
So my main domain works fine, but all subdomains get directed to the primary iBay of my SME server, not to the iBay where the correct domain resides.

I was told by GoDaddy that their system works if you have a dedicated IP address, but I have over 50 domains, and it would be cost prohibitive to have 50 IP addresses.

I have found a possible work around on the web:

Code: [Select]
1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
2. Add this line:

ServerAlias *.example.com

2. In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:

A *.example.com

Is this something that can be dome on SME server? Using a template?
If yes, please let me know how.
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #1 on: December 17, 2011, 08:43:31 PM »
Nobody knows if this can be done in SME Server?
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline rhodan

  • *
  • 12
  • +0/-0
Re: Wildcard Subdomains
« Reply #2 on: December 18, 2011, 02:03:05 PM »
You have entered and configured each of your subdomains in the domains pannel of your server-manager?
And what have you choosen for "Domain DNS servers"?

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #3 on: December 19, 2011, 04:25:07 AM »
Yes, all domains are configured and pointing to the correct iBay.
Domains resolve correctly, sub-domains are the issue (all subdomains from all domains end up in Primary iBay).
They resolved correctly with the previous registrar, problem only started when I started to use GoDaddy.

Quote
And what have you choosen for "Domain DNS servers"?

I set them as: Internet DNS servers

I did try to use: Resolve locally, on one of the domains and tried to create wildcard in Hostnames and addresses, but I was not able to, it gave me an error message saying that:

The hostname must contain only letters, numbers, and hyphens, and must start with a letter or number.
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline rhodan

  • *
  • 12
  • +0/-0
Re: Wildcard Subdomains
« Reply #4 on: December 19, 2011, 11:10:01 AM »
Quote
Yes, all domains are configured and pointing to the correct iBay.
You are not responding to my question.
Quote
You have entered and configured each of your subdomains in the domains pannel of your server-manager?

e.g.:

              domain1.com
              domain2.com
subdomain1.domain1.com
subdomain2.domain1.com
subdomain3.domain1.com
subdomain1.domain2.com
subdomain2.domain2.com
subdomain3.domain2.com


You have to point each of them to the iBay of your choice and I think you have to choose "Resolve locally" (at least for the subdomains).

This should work, if your subdomains are already resolving to your server's ip.
Quote
but all subdomains get directed to the primary iBay of my SME server

You have nothing to change in "Hostnames and addresses" if you don't want to point one (or more) of your (sub)domains to another server.
« Last Edit: December 19, 2011, 11:16:32 AM by rhodan »

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #5 on: December 19, 2011, 10:19:57 PM »
The issue is, I need to setup Wildcard Subdomains.

I have Wordpress Multiuser installed where users can open an account, since I can't anticipate what account someone will open, I need the Wildcard.

I know that in Wordpress Multiuser I can use subfolders instead of subdomins, but for SEO reasons I need to use subdomains.
« Last Edit: December 19, 2011, 10:26:01 PM by calisun »
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline rhodan

  • *
  • 12
  • +0/-0
Re: Wildcard Subdomains
« Reply #6 on: December 20, 2011, 10:37:53 AM »
I will continue with supposing.
Quote
So my main domain works fine, but all subdomains get directed to the primary iBay of my SME server, not to the iBay where the correct domain resides.
With this I can suppose:
WP-multiuser is not installed in primary
your subdomains are resolved to primary (because SME doesn't know what else to do with them)

So, have you tried putting WP-multiuser in primary, or just point primary to the WP-multiuser iBay to see whats happening?
« Last Edit: December 20, 2011, 10:45:26 AM by rhodan »

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #7 on: December 20, 2011, 07:32:52 PM »
Like I have mentioned earlier, I own over 50 domains, so I have several different installations of wordpress on the server, each in a different iBay.

SME server will not allow me to setup wildcard subdomains in the domains panel, it says that valid subdoman only contains letters and numbers.

So going back to my original question:
The suggestion I have found on another page, can it be implemented on SME using template? If yes, please let me know how.

Code: [Select]
1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
2. Add this line:

ServerAlias *.example.com

2. In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:

A *.example.com
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline rhodan

  • *
  • 12
  • +0/-0
Re: Wildcard Subdomains
« Reply #8 on: December 21, 2011, 12:23:53 PM »
I don't think that you will get an exact answer here without specifying your topology of iBays, domains and subdomains.

A quick search with the term "wildcard subdomains" at contribs points to a very old post, but may be you can still find some valuable information in it, at least a point to start.

Template friendly mods to DNS files http://forums.contribs.org/index.php?topic=13606.0

Offline Marco Hess

  • *
  • 149
  • +0/-0
    • http://www.through-ip.com
Re: Wildcard Subdomains
« Reply #9 on: January 05, 2012, 04:12:08 AM »
Here is a custom template fragment that I use to hook a PHP app onto a subdomain . Note the ServerName entry which is pulled from a config db setting and you may be able to insert a wildcard domain in there.

Code: [Select]
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/80OptSubDomainElgg

Code: [Select]
{
  my $status = $elgg{'status'} || "disabled";
  return "    # elgg-status is disabled.\n"
          unless $status eq 'enabled';

  my $domain = $elgg{'domain'} || "disabled";
  return "    # no hostname or domain for elgg defined\n"
          if $domain eq 'disabled';

  my $access = $elgg{'access'} || "disabled";
  return "    # no access setting for elgg defined\n"
          if $access eq 'disabled';

  my $DeployRoot = "/opt/elgg";
  my $DocRoot    = "$DeployRoot";

  my $allow;
  if ($access eq 'global') {
    $allow = 'All';
  } elsif ($access eq 'private') {
    $allow = join (' ', ($localAccess, $externalSSLAccess)) ;
  } elsif ($access eq 'local') {
    $allow = $localAccess;
  } else {
    # Catch all incorrect values, including empty ones
    $allow = '127.0.0.1';
  }

  $OUT  = "";
  $OUT .= "\n";
  $OUT .= "# Redirect existing hostname or domain $domain to $DocRoot.\n";
  $OUT .= "<VirtualHost 0.0.0.0:80>\n";
  $OUT .= "    ServerName  $domain\n";
  $OUT .= "    DocumentRoot $DocRoot\n";
  $OUT .= "    <Directory $DeployRoot>\n";

  $OUT .= "      AddType application/x-httpd-php .php\n";

  $OUT .= "      AllowOverride all\n";
  $OUT .= "      Options +Indexes +ExecCGI -MultiViews +FollowSymLinks\n";
  $OUT .= "      Order Deny,Allow\n";
  $OUT .= "      Deny from All\n";
  $OUT .= "      Allow from $allow\n";
  $OUT .= "    </Directory>\n";
  $OUT .= "</VirtualHost>\n";

  $OUT .= "<VirtualHost 0.0.0.0:443>\n";
  $OUT .= "    SSLEngine on\n";
  $OUT .= "    ServerName  $domain\n";
  $OUT .= "    DocumentRoot $DocRoot\n";
  $OUT .= "    <Directory $DeployRoot>\n";

  $OUT .= "      AddType application/x-httpd-php .php\n";

  $OUT .= "      AllowOverride all\n";
  $OUT .= "      Options +Indexes +ExecCGI -MultiViews +FollowSymLinks\n";
  $OUT .= "      Order Deny,Allow\n";
  $OUT .= "      Deny from All\n";
  $OUT .= "      Allow from $allow\n";
  $OUT .= "    </Directory>\n";
  $OUT .= "</VirtualHost>\n";
}

The corresponding config db settings are:

Code: [Select]
# config show elgg
elgg=service
    access=local
    domain=campfire.through-ip.com
    status=enabled

And you may be able insert a * here as a wildcard.

Have never tried it though.

Adelaide - Australia

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #10 on: April 06, 2012, 12:03:03 PM »
I don't think that you will get an exact answer here without specifying your topology of iBays, domains and subdomains.

Thank you for your concern, but I don't need advice on my topology,  all I need to know is:
does anybody know how to create custom template for Wildcard Subdomains
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #11 on: April 15, 2012, 08:30:02 AM »
Anybody is an expert on creating custom templates in SME server? I really need help to create wildcard subdomain custom template.
Help is greatly appreciated.
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: Wildcard Subdomains
« Reply #12 on: April 15, 2012, 09:19:39 AM »
calisun

Quote
I have found a possible work around on the web:
Code: [Select]
1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
2. Add this line:
ServerAlias *.example.com
2. In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:
A *.example.com
Is this something that can be dome on SME server? Using a template?

As no specific answer has yet come, then I think you should first prove or disprove that this sort of change will work on sme.
Personally I see that support for wildcards (*) is very limited in sme server (looking at various code and server manager panels etc), so I somehow think it is not supported, but that's my guess rather than knowledgable answer.
The fact that no-one has come forward with a definitive answer also suggests wildcard support is not available in sme.

You can temporarily edit httpd.conf and then restart httpd, then see if your change achieves the desired effect.
Obviously this change will be lost after a Reconfiguration (signal-event post-upgrade) and reboot.
If it does work then you can investigate further how to create the appropriate custom template.

Alternatively you can always contact Gordon Rowell (http://www.gormand.com.au/) or Charlie Brady (see bugzilla posts) who are sme experts & specialise in customising sme, for a fee (especially Gordon).
They would very quickly be able to advise you whether it's possible or not, I assume it would be worth the cost to you, if it is possible.

The obvious alternative is to switch registrars to one who does support what you want, obviously your previous registrar supported wildcards, so the "problem" is really with GoDaddys implementation, and trying to patch sme is really just a workaround. There are lots of domain registrars who provide as equally good service as GoDaddy at similar cost points.
It's usually very easy to move domains to another registrar.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline calisun

  • *
  • 601
  • +0/-0
Re: Wildcard Subdomains
« Reply #13 on: August 14, 2012, 09:16:57 AM »
Quote
Quote
    I have found a possible work around on the web:
   
Code: [Select]
1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
    2. Add this line:
    ServerAlias *.example.com
    2. In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:
    A *.example.com

Does anybody know where the DNS record file is located at?

I can do a quick manual change to httpd.conf to test it before I try to write my own custom template, but I don't know where the "DNS Records" file is located.

thank you
« Last Edit: August 14, 2012, 09:19:04 AM by calisun »
SME user and community member since 2005.
Want to install Wordpress in iBay of SME Server?
See my step-by-step How-To wiki here:
http://wiki.contribs.org/Wordpress_Multisite

Offline Jean-Philippe Pialasse

  • *
  • 2,787
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Wildcard Subdomains
« Reply #14 on: August 14, 2012, 03:12:28 PM »
Calisun,

start to answer what was asked, people that are asking need the answers to help you.


I would start with :
- Have you tried to manually set at least one of the subdomains and try if it work with the new registrar (i.e. point to the right ibay ) ?

If it does not work, the solution should be to go back to your previous registrar
Otherwise, like Mary said, try to insert the modifications you pointed at the good point for at least one ibay:

Code: [Select]
mcedit /etc/httpd/conf/httpd.confrestart webserver
Code: [Select]
service httpd-e-smith restart
and if does not work you can simply revert it with

Code: [Select]
expand-template /etc/httpd/conf/httpd.conf
service httpd-e-smith restart

if it does work, there, and only there, we can start talking about template-custom


Regarding DNS :

DNS serves an IP from a domain name, not a folder on a webserver. Obviously your clients obtain the right IP.

when contacting a webserver it is the IP that is first search whatever the domain name is, and it is only when the webserver has answered that the domain is then sent to serve the right webpage. So your problem need to be fixed with the httpd.conf file.

Regarding  subdomain list
When you say that you can not know the subdomains you need it is seems wrong to me :
- your user are registering ?
- you have a db with their username ?
- why not just creating a bash or php script launched by cron asking the list of user, then testing which subdomain are pointing to the ibay and configuring whichever is missing , every half an hour ? And this is a serious solution!