-1

Good day everyone,

I saw many documentation about cname, but it couldn't help defining what was wrong with my approach.

I am stuck on a CNAME problem. I would welcome your advice and tips there. below is an example of what I am aiming at.

assume I have the domain example.com, IP 000.000.000.000. I have a client, say client1.com, whose IP is 111.111.111.111.(IP are totally theoretical, as the rest).

This is only one of many clients, for which I provide some services (online catalogues, or whatever). that is why, on my server, I created a subdomain via cpanel : client1.example.com, where I put all scripts concerning that client1.

In order for him to access these services, I invite him to create a redirection toward this subdomain. Therefore, he created a CNAME record (via CPANEL): services.client1.com 26000 client1.example.com

Problem: it seems that this cname records points at the right IP address (000.000.000.000). If anyone uses his browser to access services.client1.com, he arrives on the example.com server (regarding IP). However, once on the example.com server, it doesn't know where to land exactly: therefore, it lands on the default-page of the domain. to sum up:

user types the url services.client1.com -->arrives on 111.111.111.111 --> server indicates that this is a cname toward client1.example.com --> arrives on 000.000.000.000 -->server doesn't know what to do with this query -->serves the default page of the domain (some cpanel cgi-script).

My question is: Is it possible, without any further implication of the client (that is, explicit redirection), that I configure the server example.com so that it points any CNAMEed query such as [l] http://services.client1.com toward the dedicated subdomain "client1.example.com" ? I was thinking of some kind of virtual host created on example.com 's server, but I couldn't work it through.

I am using a Centos virtual server for this purpose, where CPanel is installed (as well as apache server, php, and some other stuff).

I hope to be clear, and any lead might enlighten me!

Have a good one,

wisebes

2
  • Hi Cyroxx. thanks for the redirecting. Moreover, I could see at least one person having the same problem as me there. I will have a look on the posts of his thread and see if it solves my pb.In case, it doesn't, I would replace the post there. Is there a good way to proceed? thanks wisebes
    – Bes Wise
    Apr 23, 2013 at 5:01
  • The best way would be to move this question over to ServerFault and discuss it there. Is this what you want? Also, if you see differences to a related question, please edit your question to include a link and describe what you think is different. Btw: Welcome to StackOverflow!
    – cyroxx
    Apr 23, 2013 at 6:30

2 Answers 2

1

When the client tries to load services.client1.com with his browser he will contact the IP address of your server, however the browser will still send the host header containing services.client1.com. This most likely does not match any configured vhost on your server so apache delivers its default site.

You need to modify your apache vhost configuration to not only match the hostname client1.example.com but also services.client1.com

0

I figured out how to do it.

Indeed, as leepfrog pointed out, you have to modify your vhosts configuration file, in order to make that happen. the steps are the following (CENTos):

0- create the subdomain client1.example.com

1- go to the httpd.conf file (/etc/httpd/conf/httpd.conf) and uncomment the "include" part for client1.example.com. indeed, you cannot add the alias in this file, as it may be regenerated regularly. However, you may include external files. the include line enables you to include any file with extension .conf that would be located on the specified path.

2- verify the path exists, or create it if needed, and create a file.conf there.Any name will suit, as long as it finishes with ".conf".You may write the following in that file:

DocumentRoot /home/user/public_html/client1
ServerAdmin [email protected]
ServerName client1.example.com
ServerALias client1.example.com service.client1.com

NB: instead of "user" in document root, this would be your cpanel user

3- restart apache: /sbin/service httpd restart

from now on, any query to service.client1.com will be considered as an alias to the IP 000.000.000.000. Once there, the server checks the virtual hosts, compares, and sees that service.client1.com is an alias for client1.example.com subdomain. it serves the content of that local subdomain.

Et voilà!

1
  • 1
    Excellent! When you have the chance please mark this Answer as accepted. Thank you!
    – Chris S
    Apr 27, 2013 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .