Skip to main content
 首页 » 编程设计

python之nginx:[警告] 0.0.0.0:80 上的冲突服务器名称 "example.com",已忽略

2025年05月04日12luoye11

当我尝试重启 nginx 时,出现以下错误

nginx: [warn] conflicting server name "example.io" on 0.0.0.0:80, ignored 

我使用我的部署脚本为 2 个域进行部署。首先,它工作正常,但其次,它会出错。

这是我的 nginx.conf 文件

# 
worker_processes 2; 
 
# 
user nginx nginx; 
 
# 
pid /opt/nginx/pids/nginx.pid; 
error_log /opt/nginx/logs/error.log; 
 
# 
events { 
    worker_connections  4096; 
} 
 
# 
http { 
    # 
    log_format full_log '$remote_addr - $remote_user $request_time $upstream_response_time ' 
                        '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" ' 
                        '"$http_user_agent" "$http_x_forwarded_for"'; 
 
    # 
    access_log  /opt/nginx/logs/access.log; 
 
    ssl on; 
    ssl_certificate /opt/nginx/cert/example.crt; 
    ssl_certificate_key /opt/nginx/cert/example.key; 
 
    # 
    include /opt/nginx/conf/vhosts/*.conf; 
 
    # Deny access to any other host 
    server { 
        server_name example.io;  #default 
        return 444; 
    } 
} 

请您参考如下方法:

不确定,但尝试在

中更改服务器名称

/etc/nginx/sites-enabled/default

应该有帮助