{"id":296,"date":"2021-07-23T12:27:25","date_gmt":"2021-07-23T12:27:25","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/how-your-server-handles-domains-and-virtual-hosts\/"},"modified":"2021-07-23T12:27:25","modified_gmt":"2021-07-23T12:27:25","slug":"how-your-server-handles-domains-and-virtual-hosts","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/how-your-server-handles-domains-and-virtual-hosts\/","title":{"rendered":"How Your Server Handles Domains and Virtual Hosts"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>This document explains virtual hosts and how cPanel &#038; WHM handles them.<\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver1.png\" title=\"howyourserver1\"><br \/>\n<\/figure>\n<h2 id=\"an-overly-simplified-representation-of-internet-hosting\">An overly-simplified representation of internet hosting\u2026<\/h2>\n<p>The following overly-simplified outline represents how internet hosting works:<\/p>\n<ol>\n<li>\n<p>The user requests content from a remote host at a hostname (for example, the <code>example.com<\/code> domain). <\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        In most cases, the term domain name can act as a synonym for <strong>hostname<\/strong>.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>The user\u2019s computer resolves the hostname to an IP address (for example, <code>example.com<\/code> to <code>1.2.3.4<\/code>).<\/p>\n<\/li>\n<li>\n<p>The user\u2019s computer connects to the host with that IP address (<code>1.2.3.4<\/code>) and retrieves the content.<\/p>\n<\/li>\n<\/ol>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver2.png\" title=\"howyourserver2\"><br \/>\n<\/figure>\n<h2 id=\"how-it-really-works\">How it really works\u2026<\/h2>\n<p>Two significant factors complicate the overly-simplified outline:<\/p>\n<ul>\n<li>\n<p>Multiple hostnames may resolve to the same IP address (for example, <code>example.com<\/code> and <code>www.example.com<\/code> are different hostnames that likely resolve to the same IP address).<\/p>\n<\/li>\n<li>\n<p>A shared IP address can serve each hostname\u2019s content as long as the user\u2019s computer tells the remote host which hostname\u2019s content to transmit.<\/p>\n<\/li>\n<\/ul>\n<p>To allow multiple hostnames to share content via a shared IP address, we change step 3 above. The user\u2019s computer first tells the remote host the hostname\u2019s content that it wants. This way, a server that hosts content for the example.com hostname can serve completely different content for the anotherexample.com hostname. This happens even though those two hostnames use the same IP address. To the user, the content seems to originate from two different hosts. Because of this, we can say that the remote host has two different <strong>virtual hosts<\/strong> (or <strong>vhosts<\/strong>) for these names.<\/p>\n<p>A user who requests <code>example.com<\/code> content and a user who requests<code>anotherexample.com<\/code> content will receive different content. However, a host can also serve the same content for two different hostnames. For example, most users expect the same content from the <code>www.example.com<\/code> hostname as when they visit the <code>example.com<\/code> hostname. Therefore, these two hostnames exist on the same <strong>virtual host<\/strong> or <strong>vhost<\/strong>.<\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver3.png\" title=\"howyourserver3\"><br \/>\n<\/figure>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        The rest of this document discusses virtual hosts as they pertain to web hosting. However, virtual hosts can also apply to other services, such as FTP or email.\n    <\/div>\n<\/div>\n<h2 id=\"how-cpanel-whm-handles-web-virtual-hosts\">How cPanel &#038; WHM handles web virtual hosts<\/h2>\n<p>cPanel &#038; WHM streamlines how the system handles hostnames and virtual hosts in order to satisfy most common-use cases. Even though this reduces account flexibility, it guides users to generally-desirable configurations.<\/p>\n<p>Every cPanel account owns at least one web virtual host that contains two hostnames:<\/p>\n<ul>\n<li>\n<p>The account\u2019s primary domain name.<\/p>\n<\/li>\n<li>\n<p>The equivalent www. subdomain of the account\u2019s primary domain name.<\/p>\n<\/li>\n<\/ul>\n<p>So, if you create the cPanel account example with a primary domain of <code>example.com<\/code>, then HTTP requests for the hostnames <code>example.com<\/code> and <code>www.example.com<\/code> will retrieve the same content.<\/p>\n<p>cPanel users can manage three different types of additional hostnames in the <em>Domains<\/em> group of features:<\/p>\n<h3 id=\"aliases\"><em>Aliases<\/em><\/h3>\n<p>(previously <em>Parked Domains<\/em>)<\/p>\n<p>A separate hostname that the virtual host associates with the account\u2019s primary domain. For example, you can use an alias so that requests to the <code>anotherexample.com<\/code> domain to receive the same content as the <code>example.com<\/code> domain.<\/p>\n<p>Aliases also configure the equivalent <code>www.<\/code> domain to associate with the same content (for example, <code>www.anotherexample.com<\/code> domain).<\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver4.png\" title=\"howyourserver4\"><br \/>\n<\/figure>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        AutoSSL providers count aliased domains towards their domain and rate limits for virtual hosts.\n    <\/div>\n<\/div>\n<h3 id=\"subdomains\"><em>Subdomains<\/em><\/h3>\n<p>A hostname that uses the same domain name root as the account\u2019s primary domain or a parked domain, but exists on a separate virtual host (for example, <code>subdomain.example.com<\/code> and <code>other.example.com<\/code> are subdomains of the <code>example.com<\/code> domain).<\/p>\n<p>As with aliased domains, the system automatically creates an equivalent <code>www.<\/code> subdomain of the new subdomain (<code>www.subdomain.example.com<\/code>) in the virtual host for the subdomain.<\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver5.png\" title=\"howyourserver5\"><br \/>\n<\/figure>\n<h3 id=\"addon-domains\"><em>Addon Domains<\/em><\/h3>\n<p>A separate hostname on a separate virtual host. To accomplish this, cPanel creates a subdomain with the same root as the account\u2019s primary domain (for example, for the <code>anotherexample.com<\/code> addon domain, cPanel would create the <code>anotherexample.example.com<\/code> subdomain).<\/p>\n<p>Then, cPanel creates the addon domain as an alias of the subdomain (for example, cPanel creates <code>anotherexample.com<\/code> as an alias of the <code>anotherexample.example.com<\/code> subdomain).<\/p>\n<p>As with aliased domains and subdomains, the system automatically creates an equivalent <code>www.<\/code> subdomain for each new addon domain (for example, the www.anotherexample.com and <code>www.anotherexample.example.com<\/code> domains, which means that every addon domain creates a virtual host with four hostnames).<\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver6.png\" title=\"howyourserver6\"><br \/>\n<\/figure>\n<h2 id=\"ssl-encrypted-web-content\">SSL-encrypted web content<\/h2>\n<p>In order to serve SSL-encrypted web content, cPanel creates a new virtual host that mirrors the non-SSL virtual host. This new virtual host adds the necessary configuration parameters for SSL. The same hostnames associate with the new virtual host and the old one, and both virtual hosts use the same document root.<\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n        Each virtual host can <strong>only<\/strong> support one SSL certificate.\n    <\/div>\n<\/div>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/howyourserver7.png\" title=\"howyourserver7\"><br \/>\n<\/figure>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview This document explains virtual hosts and how cPanel &#038; WHM handles them. An overly-simplified representation of internet hosting\u2026 The following overly-simplified outline represents how internet hosting works: The user requests content from a remote host at a hostname (for example, the example.com domain). Note: In most cases, the term domain name can act as &hellip;<\/p>\n","protected":false},"author":1,"featured_media":297,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/296"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=296"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/296\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/297"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}