nginx-重复的默认服务器错误

标签 nginx

在我的错误日志中我得到

[emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4

在 4 号线上我有:

server_name mysite.com   www.mysite.com;

有什么建议吗?

最佳答案

您可能在 /etc/nginx/sites-enabled 中还有其他文件(例如 默认 配置)需要删除。

此问题是由于重复提供给文件中的一个或多个 listen 指令的 default_server 参数导致的。您可能会发现这个冲突的指令类似于:

listen 80 default_server;

作为nginx core module documentation for listen状态:

The default_server parameter, if present, will cause the server to become the default server for the specified address:port pair. If none of the directives have the default_server parameter then the first server with the address:port pair will be the default server for this pair.

这意味着您的配置中必须定义另一个文件或 server block ,并为端口 80 设置 default_server。 nginx 在您的 mysite 之前首先遇到该情况.com 文件,因此请尝试删除或调整其他配置。

如果您很难找到这些指令和参数的设置位置,请尝试如下搜索:

grep -R default_server /etc/nginx

关于nginx-重复的默认服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30973774/

相关文章:

nginx server_name 通配符或包罗万象

node.js - nginx/sails.js : incomplete file upload

nginx - docker运行启动服务

logging - 使用goaccess分析nginx日志

java - PlayFramework 在 http 而不是 httpS 中返回绝对 url?

nginx - kubernetes ingress server-alias 仅适用于一台 ingress 主机

nginx - 无法通过 Chef 启动 nginx 服务

list - docker restart 容器失败 : "already in use", 但没有更多的 docker 镜像

ssl - Nginx 和 SSL 给我重定向循环

nginx:设置不同服务器的特定路径