Temporary domain for hosting package

Hello,

We are a hosting company offering shared hosting packages with cPanel access. We would like to provide a temporary domain for every customer who purchases a hosting plan.

After a user buys a hosting account, they will register their own main domain name. Until that domain becomes active, we want a temporary URL to be available in the following format: cPanelusername.temporarydomain.com

This temporary subdomain should automatically be created on the server and display the contents of that user’s public_html directory (essentially acting as a mirror of their hosting account until their main domain is fully activated).

Does anyone know how to configure this so it works automatically for each new account?
If you have experience with this setup, please share the instructions or recommended approach.

Thank you in advance.

It won’t work that way.

temporarydomain.com is active and available for sale right now, apparently. I just checked.

However, assuming that you mean an currently inactive domain, i.e. example.com, then this url format:

newuser.example.com

Won’t work until example.com is active.

So what you want to do can’t be done because a subdomain can’t be contacted until the domain name is active.

In other words, example.com must exist before subdomain.example.com can be contacted.

Hi,

I think you would be better off asking on cpanel support forums:-

Being as using are posting in the RockyLinux discourse, I’m guessing you are using rockylinux on your cpanel; hopefully you are already aware of this; but just in case:-

https://support.cpanel.net/hc/en-us/community/posts/36019166354327-Rocky-Linux-Support-Deprecation-Announcement

Regards Tom.

1 Like

Hello,

It was just an example, we have active domain)

Their rationale for dumping Rocky is pretty strange.

1 Like

Doesn’t change the point I made above.

If you’re providing your customers with a temporary domain name then that temporary domain name has to exist before any subdomains under that will be reachable.

You could possibly do some hocus pocus with /etc/hosts to enable “non-official” domains but the value of doing that will depend on what you actually want to accomplish.

I’ve had shared hosting before now with access via cpanel, and my initial access was via the hosting provider’s domain. This is definitely a cpanel issue, and nothing to do with Rocky, so no idea why this question is being asked here.

Not being funny, but a hosting company would know how to do this if they are providing that service. And even with the info above it’s not enough either, since we don’t know how many hosting servers, and other potential complex configurations that a hosting company would be using. So if you are a reputable hosting provider, then you should already have the knowledge on how to do all of this, and a lot more. And also, each hosting provider will have their own specific configurations, and so nobody is going to give you instructions on how to do it, because it may not necessarily work for your situation. It would be prudent to recruit and employ people who know how to run a hosting business.

How many hosting servers? If a single server, then obviously that server has a single IP already and just needs a domain pointing at it. Even wildcard DNS can be used for *.temporarydomain.com which means at that point you only have to configure the VHOST’s on the server itself so that each client gets to their own public_html directory. And even that is configurable within cpanel as well - so again this is not an issue for this forum but rather for cpanel or whatever hosting software you are using to create your client accounts.

If you want DNS entries to be created when each client signs up, then you need an API to connect to the domain registrar for temporarydomain.com and create those entries. But in reality a wildcard is easier, since you just create one entry and that’s it forever.

I suggest asking the question on the appropriate forums. This is for Rocky Linux support, this is not a hosting provider forum. You can probably find those kind of forums with google though.

Sorry, I guess you misunderstood my request at all

We have active domain which is already added and pointed to our server, so non-existence is not the case here

Hello,

Thanks for your reply!

This question is not for cPanel as we want to configure it via VirtualHost with vhost mod (as you said)

We tried, but something went wrong, so we need some advice, we are just starting our business.

So, we have only 1 dedicated server with root access and let’s say 10 potential clients for shared hosting packages. We just want to configure virtual host to create mirroring subdomain (not actually create in cpanel) that will display their public_html content.

I know that is possible guys, that’s why I asked for help.

Thanks.

So, depending on which web server you are using, you need to provide the appropriate VHOST configuration.

For Apache, see ServerName and ServerAlias directives in Apache documentation.
For NGINX, see server_name directive in Nginx documentation.

You will either need to create the configuration files manually, or you will need to figure out a way on how you can automate it, by using for example template VHOST config files which you can replace values in and put it in the appropriate directory on the server and reload Apache or Nginx.

The rest you’ll pretty much need to figure out yourself. There’s plenty of documentation out on the internet on how to configure Apache/Nginx. If you have web server administrators, which you should have if you are a hosting company, then they should be able to figure this out when reading the appropriate documentation etc. They should also already know how to configure a vhost.

So what exactly did you try? If you don’t post what you did and the actual specifics in how you configured it, and show what went wrong, nobody can help.

But also, nobody here is going to give you the complete solution for free. People here can help guide you in finding a solution, but you will have to put in a lot more effort to learn how to do all of this yourself, by reading documentation on web servers, how to configure vhosts, etc, etc. Because if you don’t know how to do it, how do you expect to fix problems if your hosting service fails and you don’t know how it’s configured?

  • Created wildcard record for our domain to point it to the server

  • Enabled mod_vhost_alias

  • Added this code to the main virtualhost file in apache:

    <VirtualHost *:80>

    ServerName example.com

    ServerAlias *.example.com

    VirtualDocumentRoot /home/%1/public_html

No errors, it just do not create mirroring subdomain subdomains

We missed some step or virtualhost is not valid

So from a quick google, would suggest you have it configured wrong, see: https://stackoverflow.com/questions/22421352/apache-httpd-virtual-host-what-is-1-in-a-document-root

so it in theory could be %1+ and not just %1. That’s assuming everything else is configured correctly, and what the actual directory structure on disk is, and if the appropriate user has access to the files. Selinux could also be blocking if incorrectly configured, so you also need to look at that.

This link also from the above link, is the Apache docs that has even more detail: mod_vhost_alias - Apache HTTP Server Version 2.2

If it still doesn’t work, check your log files.

Tried %1 and %1+, websites started displaying 404 not found

Obviously, something is wrong with the path, but I can’t understand what’s erong and logs are empty:

VirtualDocumentRoot /home/%1/public_html

Any 404 should definitely be logged.

Are you sure you’re looking in the right place for the apache logs? By default they go into /var/log/httpd and there are two logs there, access_log and error_log.

error_log is probably what you need to look at.

Yep, I checked /var/log/apache2/error_log and access_log

No triggers when I open those pages

I just want to check somewhere which path it is trying to open

That is not the usual default location for apache logs on Red Hat systems.

Did you change it? The usual place to look for those logs is in /var/log/httpd. The apache2 directory is usually used for Ubuntu-type systems, not rhel.

Does anything show up in the logs under your apache2 directory? If there’s nothing getting logged at all, then that’s because you’re looking in the wrong place.