【问题标题】:How to configure multiple sub-domain in nginx?nginx如何配置多个子域?
【发布时间】:2016-03-10 06:50:12
【问题描述】:

我想向托管在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;
           }
    }
  }

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

【问题讨论】:

  • 您是否已将它们添加到 DNS 中?
  • 那是错误。完全忘记添加了。刚刚添加了*.example.com,它起作用了。谢谢。

标签: ubuntu nginx configuration server


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-09-05
    • 2013-07-08
    • 2012-04-11
    • 2018-05-21
    • 2017-03-31
    • 2014-01-24
    • 1970-01-01
    • 2018-12-19
    • 2013-12-04
    相关资源
    最近更新 更多