如何将cname指向使用反向代理的nginx服务器

如何将cname指向使用反向代理的nginx服务器,nginx,wildcard-subdomain,nuxtjs,Nginx,Wildcard Subdomain,Nuxtjs,我有一个使用通配符子域的服务器。我使用的是在3000端口的反向代理上运行的nuxtjs,nginx。每个用户都应该能够在站点上创建子域,例如subdomain.learnbot.tk,然后指向learnbot.tk/school/{subdomain name}。每个用户都应该能够创建一个指向自己的子域.learnbot.tk的cname 但是当我创建一个CNAME记录时,主机为@,目标为subdomain.learnbot.tk使用域名https://creatorbrandedsite.tk

我有一个使用通配符子域的服务器。我使用的是在3000端口的反向代理上运行的nuxtjs,nginx。每个用户都应该能够在站点上创建子域,例如
subdomain.learnbot.tk
,然后指向
learnbot.tk/school/{subdomain name}
。每个用户都应该能够创建一个指向自己的
子域.learnbot.tk
的cname

但是当我创建一个CNAME记录时,主机为
@
,目标为
subdomain.learnbot.tk
使用域名
https://creatorbrandedsite.tk/
它返回404

以下是我的通配符子域配置文件:

        server {
        listen 80;
    
        server_name *.learnbot.tk;
        return 301 https://$server_name$request_uri;
    }
    
    server {
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;
        #include snippets/ssl-example.com.conf;
        #include snippets/ssl-params.conf;
    
        ssl_certificate /etc/letsencrypt/live/learnbot.tk/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/learnbot.tk/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
        root /home/subdomain/learnbot.tk/public/current;
        index index.php index.html index.htm index.nginx-debian.html;
    
        server_name *.learnbot.tk;
    
        location / {
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    
        location /blog {
            try_files $uri $uri/ /index.php$is_args$args;
        }
    
        # For Lets Encrypt certbot
        location ~ /.well-known {
            allow all;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
    
        location ~ /\.ht {
            deny all;
        }
    
        location /favicon.ico { alias /var/www/html/example/favicon.ico; }
        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
}
主域的nuxtjs配置文件

    server {
    index index.html;
    server_name learnbot.tk www.learnbot.tk;

    location / {
        # WARNING: https in proxy_pass does NOT WORK!! I spent half a day debugging this.
        #proxy_pass https://localhost:4001;
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    
    error_page 404 /custom_404.html;
    location = /custom_404.html {
        root /etc/nginx/sites-available/custom_nginx_error_pages;
        internal;
    }

    listen [::]:443 ssl http2; # managed by Certbot, modified by Kunal to add http2
    listen 443 ssl http2; # managed by Certbot, modified by Kunal to add http2

    #Install SSL certificates and configure https:// on a per-domain-basis by running:
    #sudo certbot --nginx
    #(when prompted, be sure to select the option to set up redirects from http to https and effectively "disable" http)
    ssl_certificate /etc/letsencrypt/live/learnbot.tk/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/learnbot.tk/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    server_name learnbot.tk;
    if ($host = learnbot.tk) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;
    return 404; # managed by Certbot
}