尝试在同一端口中设置域和子域。(NGINX)

Non*_*Non 1 regex .htaccess http nginx

我正在尝试使用 Nginx 在同一端口中运行域和子域,但尚未成功。

我有一个名为www.just4bettors.mobi用于移动页面的域,并且子域的名称必须www.desktop.just4bettors.mobi明确用于桌面站点。

如果您输入www.just4bettors.mobi一切正常,您将到达该页面,但如果您输入,www.desktop.just4bettors.mobi您将看到This web page is not available. 这是我到目前为止拥有的服务器块

server {
        large_client_header_buffers 1 1K;

        listen       80;
        server_name  ~^(?<subdomain>[^.]*)\.?just4bettors.mobi$ just4bettors.mobi;
        root   /home/c0pt/capilleira/capilleiraclickandgamblemobile/www;

        location / {
            if ($subdomain) {
               root /home/c0pt/capilleira/capilleiraclickandgambleweb/dist;
            }
            if ($host = "just4bettors.mobi") {
                root /home/c0pt/capilleira/capilleiraclickandgamblemobile/www;
            }
            index  index.html index.htm;
            ...
        }
}
Run Code Online (Sandbox Code Playgroud)

一旦我尝试访问desktop.just4bettors.mobi,控制台就会返回此GET http://desktop.just4bettors.mobi/ net::ERR_NAME_NOT_RESOLVED

你会发现这里的根源是不同的,移动和网络生活在不同的地方。

那么,我在这里缺少什么?

Don*_*dez 5

我管理过使用数百万个不同域的 Nginx 配置。尝试在一个块指令内工作是非常复杂的server{}。这是我要做的:

server {
    large_client_header_buffers 1 1K;
    listen 80;

    server_name www.just4bettors.mobi;
    root /home/c0pt/capilleira/capilleiraclickandgamblemobile/www;

    location / {
        ...
    }
}

server {
    large_client_header_buffers 1 1K;
    listen 80;

    server_name www.desktop.just4bettors.mob;
    root /home/c0pt/capilleira/capilleiraclickandgambleweb/dist;

    location / {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

您可以在这里阅读更多相关信息:http://wiki.nginx.org/Pitfalls#Server_Name