How to set up subdomains like blogspot

What needs to be done to set up a subdomain for users when they register on my site.

What is the necessary infrastructure? I am using Linux servers.

+4
source share
5 answers

You can record CNAME / A Record in DNS settings for each subdomain

A CNAME record is an entry in your Domain Management Settings that allows you to manage the subdomain of your domain.

To automate it along with registration, you can write a script that runs for each user when he / she registers.

You can also refer to this link for a step-by-step process for Apache:

How to configure subdomains in apache

(since you mentioned Linux, I assume it should be APache. Indicate if so)

Alternative solution

You can also refer to the substitution solution given by Alnitak , in the same thread. I find it simpler. :)

+3
source

You can use a specific DNS record ( CNAME or A / AAAA ) for each known subdomain or a wild-card DNS record that will accept * .example.com:

 $ORIGIN example.com foo IN A 12.34.6.78 bar IN A 12.34.6.78 

or

 $ORIGIN example.com * IN A 12.34.6.78 

The advantage of the latter is that after the service is started, no DNS or Apache configuration changes are required. The disadvantage is that all such wildcards must (by definition) return the same IP address.

Apache configuration will depend on your requirements, both for end-user management and security. Note that if users have permission to run CGI scripts on the server, additional configuration will be required to ensure this is completed reliably.

Depending on whether the content is static or dynamic, this will also affect your configuration:

  • Use mod_vhost_alias to map individual virtual hosts in their separate directories on the server.

  • If you really want to, create a separate <VirtualHost> section for each known site, but then you will have to restart Apache every time a new user signs up

  • Use one <VirtualHost> , and then look at the host name part of the requested URL (from the $SERVER_NAME environment variable) in the scripts that display the output for displaying the contents of the user.

+6
source

The infrastructure includes access to a DNS server to add wildcard entries and rewrite rules in Apache.

Try the following answers:

or this link:

0
source

If you are using a Linux server, I assume that you are using Apache as your web server.

You need to configure the correct DNS routing for the subdomain, as well as for the virtual host.

Virtual hosts are pretty easy to set up, but I'm not sure how easy it is to make them on the fly progmatically.

In most cases, it is as simple as editing the apache configuration file and adding the following:

 Port 80 ServerName www.mydomain.com NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /www/user-bob ServerName bob.mydomain.com ... </VirtualHost> <VirtualHost *:80> DocumentRoot /www/user-sally ServerName sally.mydomain.com ... </VirtualHost> 

VirtualHost Documention will probably be of use to you.

0
source

Apache allows you to specify any number of "sites" based on subdomains on a single server. Creating a new site definition file with the appropriate information about the subdomains in it along with the corresponding DNS wildcards will do what you want.

In other words, the process is as follows:

  • Install the templates so that * .mysite.com is directed to the appropriate server.
  • When the new user signs up, create the correct Apache site definition file - you will probably have a basic template in which you put the correct subdomain information and save it.
  • Make Apache re-read its configuration.
  • Profit

IMPORTANT This is based on a Debian-style Apache configuration, where the configuration files are included in the directory, and the main configuration reads all the configuration files in this directory. This will simplify a lot, because adding / removing subdomains will mean adding / removing files, rather than editing a single file, and therefore the process will be much easier to automate.

0
source

All Articles