有关nginx子域配置的SO有几个问题,但没有找到与我完全相同的问题.
假设我从我们组织的高级网络管理示例网站获得了一个虚拟主机some.example.com.我想使用some.example.com作为我的主站点,并使用foo.some.example.com和bar.some.example.com进行辅助使用(代理等).我尝试了这个简单的配置并将其置于已启用网站但未起作用的情况下:
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;
}
在此设置中,some.example.com工作正常,但对于另外两个无法找到foo.some.example.com的浏览器返回.我在ubuntu服务器上运行它.
这个配置有问题吗?或者是我应该与更高级别的网络管理员交谈(使foo.some.example.com和bar.some.example.com注册)?
最佳答案
子域配置以父域的DNS服务器中的条目开始,并且查找将子域解析为Web服务器的IP地址. Web服务器依次根据子域的配置委托请求.
如果您的子域中没有DNS设置,则example.com上的admin需要设置CNAME别名.别名将子域指向同一Web服务器,该服务器承载父域的网站.为每个子域添加规范名称(CNAMES).一旦子域解析为Web服务器的IP地址,Web服务器就可以将请求路由到其他网站.