How to recognize specific host name for Visual hosts?

ccw

Member
Apr 20, 2019
5
0
1
China
cPanel Access Level
Root Administrator
Hi,

Current my website www.example.com is hosted on a dedicated server with cPanel. Users can visit my website via www.example.com or example.com.

Now I need to use my website as the origin and use Amazon Cloudfront distribution for it as a CDN. Amazon Cloudfront does not allow to use an IP address as the origin, neither can I use www.example.com or example.com as the origin domain, since they will point to the distribution after I setup the Cloudfront distribution.

So I add a new A record in the DNS zone editor, i.e.

web.example.com. -> 12.34.56.78(IP of the dedicated server)

And then take web.example.com as the origin domain.

Now the problem is that Cloudfront will include the following header to the request:

Host: web.example.com

And I cannot modify the header.

And then such a Host header is passed to my server, it seems that the server cannot accept the Host web.example.com as a valid host name for example.com and will always return 404 error below:

"The server cannot find the requested page"

"web.example.com/wp-admin/ (port 443)"

So now what I need to do is to let web.example.com to be another valid host name for example.com, just like www.example.com. How to do so?

Thanks
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Hey there! You'd want to either create a subdomain (separate web content) or an alias (points to already-existing web content) through cPanel. In order to that, you'd do the following:

-delete the DNS entry you have already created
-log in to cPanel for the domain
-go to Aliases
-create the domain/subdomain you'd like to use

Can you try that and see if that gets things working how you expect? More details on that can be found here: Aliases | cPanel & WHM Documentation