大网数据广告活动
服务器运维问答

Changing A record and CNAME records

· 52CE 我爱测

Currently I'm using a LAMP configuration for both my landing page page, for the web app, and for the APIs. Now I'd like to split these things across multiple Virtual Servers (VS). I'm unsure of the network settings and before mes…

问题原文

原帖链接 · don · CC BY-SA 3.0

Currently I'm using a LAMP configuration for both my landing page page, for the web app, and for the APIs. Now I'd like to split these things across multiple Virtual Servers (VS). I'm unsure of the network settings and before messing up all my DNS configurations I'd like to understand if I'm about to crash my configuration.

The landing page is hosted at the second level domain (e.g. myurl.com), the web app is hosted at the lower level domain app.myurl.com, and the api at api.myurl.com. I also have a preview domain: preview.myurl.com, used for testing.

Since everything is hosted on the same VS, I currently have also four different folders (landing, api, webapp, preview), that act as "virtual hosts" for each subdomain.

My DNS configuration looks like this:

myurl.com.  A   300 123.123.123.123
www.myurl.com.  CNAME   300 myurl.com.
api.myurl.com.  CNAME   300 myurl.com.
app.myurl.com.  CNAME   300 myurl.com.
preview.myurl.com.  CNAME   300 myurl.com.

To start I'd like to change the data of each CNAME entry to the actual IP of the current VS. So that it would look like this:

myurl.com.  A   300 123.123.123.123
www.myurl.com.  CNAME   300 myurl.com.
api.myurl.com.  CNAME   300 123.123.123.123
app.myurl.com.  CNAME   300 123.123.123.123
preview.myurl.com.  CNAME   300 123.123.123.123

Then the idea is to point each subdomain to the proper VS. Initially all lower level domains (except for www.) will still be pointing to the current VS, while the second level domain for the landing page (A record for myurl.com.) will need to point to a new IP for a new VS.

Questions:

  1. Will these changes affect the way in which the current Apache Server is distributing the traffic to each subfolder (i.e. landing, api, webapp, preview)? If so, even if all IP addresses remain the same?
  2. To test things out, could I start by changing only the data value for preview.myurl.com. without risking of compromising the rest?
  3. Once all lower level domains (e.g. api.myurl.com) point to the IP of the VM, can I point the A value of myurl.com. to a different IP without compromising the other lower level domains (api, app, preview)?

已采纳解答

原帖链接 · Dre · CC BY-SA 3.0

As mentioned in the comments, you will need to use A records instead of CNAME records. CNAME records will not be able to point at an IP Address.

The key to making each of the sites to work is to specify ServerName correctly for each virtual server in your Apache config.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。