ubuntu - 如何在nginx中配置多个子域?

标签 ubuntu nginx configuration server

我想为托管在 nginx 上的网站添加子域。为此,我将子域名添加到 nginx.conf 文件中。但是每当我尝试访问本地主机之外的子域时,它都会将我重定向到 http://id.domain-error.com/noresult.php

这是我的 nginx.conf 文件:

http {

    server {
    listen 80; # Incoming port for Nginx
    server_name www.example.com example.com;
    index index.html index.htm;
    location / {
           root /usr/share/nginx/example;
           try_files $uri $uri/ =404;
           }
    }
    server {
    listen 80; # Incoming port for Nginx
    server_name hello.example.com;
    index index.html index.htm;
    location / {
           root /usr/share/nginx/some_other_example;
           try_files $uri $uri/ =404;
           }
    }
  }

谁能告诉我这里缺少什么?

最佳答案

正如@Alexey 所指出的,我需要在 DNS 配置中添加子域。我只是添加了一个通配符 *.example.com 并且它开始工作了。

关于ubuntu - 如何在nginx中配置多个子域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35909499/

相关文章:

java - 跨Java系统的配置设计模式

ubuntu - RabbitMQ On Ubuntu 14.04 服务器配置

升级系统后 PHP 和 Smarty 编译延迟

ruby-on-rails - 薄型或美洲狮 : What to use for a Rails Chat server using Faye?

php - laravel 项目上出现 403 Forbidden,但没有其他内容

docker - Docker容器上的Google App Engine Flex运行状况检查

c# - Ubuntu(Wine)下的屏幕截图

linux - 如何将代理列表从\n 替换为\r\n

java - 用于管理多个 Web 应用程序配置的工具

linux - 根据conf文件替换文件的值