子域是通过域注册器或网络服务器创建的?
subdomain is created via domain regitrar or web server?
我正在使用 Docker Nginx 服务器和 Lumen 托管 API 服务器,比方说 example.com,但现在我想将其更改为 api。example.com。我尝试通过添加 server_name 来编辑我的 nginx.conf:api.example.com 但它没有用,但我仍然能够访问 example.com.
server {
listen 80;
server_name api.example.com;
root /app/public;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /index.php {
include fastcgi_params;
fastcgi_connect_timeout 10s;
fastcgi_read_timeout 10s;
fastcgi_buffers 256 4k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
}
}
然后我在 namecheap.com(我从那里购买域名)上找到了一个教程,我可以通过 CNAME 记录创建子域。
现在我很困惑子域是如何创建的?从服务器配置还是从域注册器?
谢谢
您需要设置域名注册和服务器配置。 cname 会将请求 chris.example.com
发送到您的服务器在互联网上的实际位置 192.168.1.1
(或者它的 IP 是什么)。然后您需要在服务器的配置文件夹中设置 chris.example.com
,以便加载 chris.example.com
代码库,而不是 example.com
代码库。
当您输入 domain.com
时,它会转到 DNS 服务器并将其映射到 IP 地址。然后请求转到该 IP,服务器根据给定的域名决定加载什么。 (TTL 是 IP 地址应该在本地保持映射到域名的时间长度(因此您不必对您已经知道的域执行多个 DN 查询))。
我正在使用 Docker Nginx 服务器和 Lumen 托管 API 服务器,比方说 example.com,但现在我想将其更改为 api。example.com。我尝试通过添加 server_name 来编辑我的 nginx.conf:api.example.com 但它没有用,但我仍然能够访问 example.com.
server {
listen 80;
server_name api.example.com;
root /app/public;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /index.php {
include fastcgi_params;
fastcgi_connect_timeout 10s;
fastcgi_read_timeout 10s;
fastcgi_buffers 256 4k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
}
}
然后我在 namecheap.com(我从那里购买域名)上找到了一个教程,我可以通过 CNAME 记录创建子域。
现在我很困惑子域是如何创建的?从服务器配置还是从域注册器?
谢谢
您需要设置域名注册和服务器配置。 cname 会将请求 chris.example.com
发送到您的服务器在互联网上的实际位置 192.168.1.1
(或者它的 IP 是什么)。然后您需要在服务器的配置文件夹中设置 chris.example.com
,以便加载 chris.example.com
代码库,而不是 example.com
代码库。
当您输入 domain.com
时,它会转到 DNS 服务器并将其映射到 IP 地址。然后请求转到该 IP,服务器根据给定的域名决定加载什么。 (TTL 是 IP 地址应该在本地保持映射到域名的时间长度(因此您不必对您已经知道的域执行多个 DN 查询))。