设置 nginx 配置以使所有域都转到一个服务器块(除了一个)
需要做什么才能实现以下服务器配置?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是为
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 towww.specialdomain.com specialdomain.com
, and the other block should have it set tolocalhost
.