虚拟主机上的nginx子域配置

clw*_*wen 7 subdomain dns webserver nginx

有关nginx子域配置的SO有几个问题,但没有找到与我完全相同的问题.

假设我的组织中有some.example.com来自更高级别网络管理员的虚拟主机example.com.我想some.example.com用作我的主站点并使用foo.some.example.combar.some.example.com辅助使用(代理等).我尝试了这个简单的配置并将其置于sites-enabled但不起作用:

server {
    listen 80; 
    server_name some.example.com;
    root /home/me/public_html/some;
    index index.html index.htm;
}

server {
    listen 80; 
    server_name foo.some.example.com;
    root /home/me/public_html/foo;
    index index.html index.htm;
}

server {
    listen 80; 
    server_name bar.some.example.com;
    root /home/me/public_html/bar;
    index index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)

在这个设置下some.example.com工作正常,但对于其他两个浏览器返回could not find foo.some.example.com.我在ubuntu服务器上运行它.

这个配置有问题吗?或者我应该与更高级别的网络管理员(制作foo.some.example.combar.some.example.com注册)交谈?

Bri*_*ght 11

子域配置以父域的DNS服务器中的条目开始,并且查找将子域解析为Web服务器的IP地址.Web服务器依次根据子域的配置委托请求.

如果您的子域中没有DNS设置,则example.com上的admin需要设置CNAME别名.别名将子域指向同一个Web服务器,该服务器承载父域的网站.为每个子域添加规范名称(CNAMES).一旦子域解析为Web服务器的IP地址,Web服务器就可以将请求路由到其他网站.