Wilcard域中使用Digitalocean和nginx捕获所有请求到子域

发布于 2025-01-25 00:50:44 字数 1181 浏览 2 评论 0原文

我有大量的子域,列表继续增长。

我最近开始使用数字海洋,需要重新创建子域列表,但是使用DNS服务器控制面板一个一个一个一个一个一个创建它们的过程非常耗时,除此之外,只要我需要创建一个新的子域,我就必须手动做。

我正在尝试创建一个通配符域,以便所有子域都由DNS服务器捕获,然后每个子域都重定向到特定服务。

将使用的服务是ODOO,它将与Nginx一起使用。

到目前为止,我已经做了什么:

  • 我注册了新的域名(example.com);
  • 更新了域名服务器以指向数字海洋(ns1.digitalocean.com,ns2.digitalocean.com,ns3.digitalocean.com);

在数字海洋的DNS控制面板中,我创建了以下DNS记录:

a *.example.com xxx.xxx.xxx.xxx.xxx 3600

cname www.example.com example.com 43200

example.com xxx.xxx.xxx.xxx.xxx 3600

ns example.com ns1.digitalocean.com 1800

ns example.com ns example.com

ns2.digitalocean.com .com ns3.digitalocean.com 1800

用于记录“ example.com”和“ www.example.com”一切似乎都在起作用,因为当我ping时,我看到流量被重定向到数字海洋液滴。

在nginx中,我创建了一个服务器块,并将其包含在服务器中:

使用此配置的服务器{

 ...
 server_name example.com www.example.com *.example.com .example.com test.example.com;

 ...

}

我可以使用地址轻松访问ODOO服务器: “ nofollow noreferrer”> www.example.com 但是,当我尝试访问地址时” test.example.com “我无法访问服务器。

肯定有必要执行通过我的更多步骤,而我在搜索中找不到?

I have a large list of subdomains and the list continues to grow.

I recently started using Digital Ocean and I need to recreate the list of subdomains but the process of creating them one by one using the DNS Server control panel is very time consuming and besides that, whenever I need to create a new subdomain I will have to do it manually.

I'm trying to create a wildcard domain so that all subdomains are captured by the DNS server and then each one is redirected to the specific service.

The service that will be used is Odoo and it will work together with Nginx.

What I've done so far:

  • I registered the new domain name (example.com);
  • Updated the Domain Name Servers to point to Digital Ocean (ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com);

In the DNS control panel at Digital Ocean, I created the following DNS records:

A *.example.com xxx.xxx.xxx.xxx 3600

CNAME www.example.com example.com 43200

A example.com xxx.xxx.xxx.xxx 3600

NS example.com ns1.digitalocean.com 1800

NS example.com ns2.digitalocean.com 1800

NS example.com ns3.digitalocean.com 1800

For the records "example.com" and "www.example.com" everything seems to be working because when I ping I see that the traffic is redirected to the Digital Ocean droplet.

In Nginx I created a server block and included as servers:

server {

 ...
 server_name example.com www.example.com *.example.com .example.com test.example.com;

 ...

}

With this configuration I can easily access the Odoo server using the addresses: example.com and www.example.com but when I try to access the address "test.example.com" I cannot access the server.

Surely it will be necessary to perform some more step that passed me and I didn't find in my searches?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

或十年 2025-02-01 00:50:44

我发现在测试期间,我在 /etc /hosts文件中放置了以下记录:

127.0.0.1 test.example.com

在删除此记录后,一切都按预期工作。

I found that during the tests I had placed a record in the /etc/hosts file with:

127.0.0.1 test.example.com

After removing this record, everything is working as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文