Temp URL to access domain before DNS propagation

electric

Well-Known Member
Nov 5, 2001
742
5
318
Does cpanel have the ability to use a subdomain instead of http://serverIP/~username method for temporary URL access before a customer's domain is pointing to the server?

For improved security, we don't want to enable the mod_userdir or the ability to access accounts using the server IP.

But otherwise.. the only way the customer can see their website files is to use a local "hosts" file... and that is really too complicated for the majority of our customers.

It would be nice if there was a way cpanel could automatically create a subdomain that runs off the server hostname, for each account.

For example:

http://AccountUsername.serverHostname.com

Is this possible?
 

jfall123

Well-Known Member
Oct 31, 2005
55
2
158
Not that I know of, but I fail to understand how/why you think that method would be any more secure than serverip/~user
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,234
363
cPanel Access Level
DataCenter Provider
Twitter
Hello,

You'd have to manually add the subdomain to the cPanel account as an alias (parked domain) for that to work. Additionally, you'd need to enable the following option under the "Domains" tab in "WHM >> Tweak Settings":

Allow users to park subdomains of the server’s hostname.

Note that we do have a document on modifying the hosts file on a local computer should the end-users need help setting it up:

How to Modify your hosts File - cPanel Knowledge Base - cPanel Documentation

Thank you.
 

electric

Well-Known Member
Nov 5, 2001
742
5
318
You'd have to manually add the subdomain to the cPanel account as an alias (parked domain) for that to work. Additionally, you'd need to enable the following option under the "Domains" tab in "WHM >> Tweak Settings":

Allow users to park subdomains of the server’s hostname.
OK, I enabled that setting in the WHM "Tweak Settings", and then logged into the customer's cpanel account and tried to add a subdomain of the server hostname. I got this error:

---------------
There was an error when the system attempted to create the alias. Park::park failed: (XID a3wpm2) The domain “username.unique.ServerHostname.com” may not be created by “username” because “ServerHostname.com” is already owned by another user.
---------------

Do you have any idea what might be the problem?
 
Last edited:

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
If there were a Park a Domain in the WHM API, that would help immensely. You could then create a hook to do this.

But the calls for a WHM API Park a Domain function have been there for years and there's been no movement on that front.
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,234
363
cPanel Access Level
DataCenter Provider
Twitter
may not be created by “username” because “ServerHostname.com” is already owned by another user.
You'd also need to enable:

"Allow cPanel users to create subdomains across accounts"

Note that you should disable these options after you create the subdomains to avoid misuse of this feature from cPanel users.

Thank you.
 

electric

Well-Known Member
Nov 5, 2001
742
5
318
You'd also need to enable:

"Allow cPanel users to create subdomains across accounts"

Note that you should disable these options after you create the subdomains to avoid misuse of this feature from cPanel users.

Thank you.
I also tried using the WHM "Park a Domain" page, and this function allowed the subdomain "username.unique.ServerHostname.com" to be added successfully. (I am logged into WHM as root user.)

However, when I go to the URL in my browser, it shows this page:

http://username.unique.ServerHostname.com/cgi-sys/defaultwebpage.cgi

It does not show the customer's website files, which I parked this hostname on top of. (I know the subdomain was added to the server, because I can actually see the "username.unique.ServerHostname.com" subdomain listed in the customer's cpanel account in the "aliases" page.)

Any ideas what is the problem?
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,234
363
cPanel Access Level
DataCenter Provider
Twitter
Hello,

Can you reproduce the same behavior when removing it as a WHM parked domain name, and instead adding the subdomain using "cPanel >> Aliases"?

Thank you.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
I would try restarting Apache first.

Perhaps the DNS entry was made but Apache did not restart after adding the ServerAlias.

Additionally running:

Code:
grep -B1 username.unique.ServerHostname.com /etc/apache2/conf/httpd.conf
Should produce something and should show ServerName theusersmaindomain.tld
 

electric

Well-Known Member
Nov 5, 2001
742
5
318
Hello,

Can you reproduce the same behavior when removing it as a WHM parked domain name, and instead adding the subdomain using "cPanel >> Aliases"?

Thank you.
Yes, the exact same behavoir happens when I try that. Here is what I tried:

1. Enable the following two "Tweak Settings" in WHM:

Allow users to park subdomains of the server’s hostname.
Allow cPanel users to create subdomains across accounts.

2. Login to customer's cpanel, and go to "Aliases" page.

3. Try to create alias for "http://username.unique.ServerName.com". It says it works. However, if I go to the URL, then I see the generic page:

http://username.unique.ServerName.co/cgi-sys/defaultwebpage.cgi

So it seems the exact same problem happens, regardless of whether the subdomain is created in WHM using "Park a domain" page or the cpanel "Alias" page.

Any ideas?
 

electric

Well-Known Member
Nov 5, 2001
742
5
318
Hello,

Can you reproduce the same behavior when removing it as a WHM parked domain name, and instead adding the subdomain using "cPanel >> Aliases"?

Thank you.
Yes, the exact same behavoir happens when I try that. Here is what I tried:

1. Enable the following two "Tweak Settings" in WHM:

Allow users to park subdomains of the server’s hostname.
Allow cPanel users to create subdomains across accounts.

2. Login to customer's cpanel, and go to "Aliases" page.

3. Create an alias for "username.unique.ServerName.com". It says it works. However, if I go to the URL, then I see the generic page:

http://username.unique.ServerName.com/cgi-sys/defaultwebpage.cgi

So it seems the exact same problem happens, regardless of whether the subdomain is created in WHM using "Park a domain" page or the cpanel "Alias" page.

Any ideas?
 
Last edited:

electric

Well-Known Member
Nov 5, 2001
742
5
318
I would try restarting Apache first.

Perhaps the DNS entry was made but Apache did not restart after adding the ServerAlias.
I tried restarting apache, but that did not make any difference. The problem continues with no change.

Additionally running:

Code:
grep -B1 username.unique.ServerHostname.com /etc/apache2/conf/httpd.conf
Should produce something and should show ServerName theusersmaindomain.tld
Yes, here is the output the command produces:


Code:
root [/]# grep -B1 username.unique.ServerHostname.com /etc/apache2/conf/httpd.conf
  ServerName TheUsersMainDomain.tld
  ServerAlias username.unique.ServerHostname.com mail.TheUsersMainDomain.tld mail.username.unique.ServerHostname.com www.TheUsersMainDomain.tld www.username.unique.ServerHostname.com
root [/]# _
Does it matter that TheUsersMainDomain.tld is not currently pointing to our servers? (The customer has not changed the nameservers for this domain yet, so it still points to the old hosting provider.)

Any ideas?
 

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
Is theusersmaindomain.tld using a dedicated IP?

When theusersmaindomain.tld was set up, what IP address was it given in the New Account message?

What IP address does username.unique.serverhostname.com resolve to?

Is it the same IP address?