设置 nginx 配置以使所有域都转到一个服务器块(除了一个)

发布于 2024-11-16 10:09:27 字数 257 浏览 4 评论 0原文

需要做什么才能实现以下服务器配置?

abc.com、def.com、ghi.com 和所有其他都指向此 IP ->服务器块

A.specialdomain.com ->服务器块 B。

我尝试创建两个服务器块,一个使用 server_name localhost 并默认监听 8080,另一个使用 server_namespecialdomain.com 并监听 8080,但它将所有请求通过管道传输到第一个服务器块。

What would need to be done to achieve the following server configuration?

abc.com, def.com, ghi.com, and all others pointed to this IP -> server block A.

specialdomain.com only -> server block B.

I've tried creating two server blocks, one with server_name localhost with listen 8080 default, another with server_name specialdomain.com with listen 8080, but it's piping all of the requests to the first server block.

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

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

发布评论

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

评论(1

酸甜透明夹心 2024-11-23 10:09:27

解决方案是为 specialdomain.com 设置一个特定的 nginx conf 块,然后为其余部分设置一个通用的通用 nginx 配置块。

一个块应将 server_name 设置为 www.specialdomain.comspecialdomain.com,另一个块应将其设置为 localhost

The solution is to set up one specific nginx conf block for specialdomain.com, then have a general catch-all nginx config block for the rest.

One block should have the server_name set to www.specialdomain.com specialdomain.com, and the other block should have it set to localhost.

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