GrepBoard/매뉴얼
605 편 ·

conflicting server name ... ignored 해결

·시험 환경 nginx 1.30.6·1.31.8 (Docker) · Ubuntu 24.04 nginx 1.24.0 · 2026-10·시험 범위 ↓·6 단계

nginx conflicting server name ... ignored 는 같은 주소·포트에 같은 server_name 이 두 번 있다는 뜻입니다. 뒤 블록은 무시되므로 nginx -T 로 중복을 찾아 지웁니다.

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

같은 주소·포트(0.0.0.0:80)에 server_name example.com 을 가진 server 블록이 둘 이상 있다는 경고입니다. 먼저 읽힌 블록이 그 이름을 갖고, 뒤에 나온 블록의 그 이름은 무시됩니다. 경고라서 nginx -t 는 성공하지만, 고친 설정이 반영되지 않는 원인이 이것인 경우가 많습니다. Ubuntu 에서는 sites-enabled/ 에 남은 백업 파일이 흔한 원인입니다.

[1] 경고 줄을 모두 봅니다. 이름과 주소·포트마다 한 줄씩 나오므로, listen [::]:80; 도 있으면 같은 이름으로 두 줄이 나옵니다.

output
nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignorednginx: [warn] conflicting server name "example.com" on [::]:80, ignorednginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

포트가 다르면 충돌이 아닙니다. 같은 example.com 을 80 과 8080 에 둔 설정은 경고 없이 통과했습니다.

[2] 어느 블록이 응답하는지 확인합니다. 두 블록에 example.com 을 두고, 두 번째 블록에만 www.example.com 을 더한 설정입니다.

console
$ curl -s -H 'Host: example.com' http://127.0.0.1/first$ curl -s -H 'Host: www.example.com' http://127.0.0.1/second

example.com 은 먼저 나온 블록(first)이 받았고, 두 번째 블록은 겹치지 않는 www.example.com 만 받았습니다. 블록 하나만 고쳤는데 변화가 없다면 고친 쪽이 무시되는 블록일 수 있습니다.

[3] 같은 이름이 어느 파일 몇 번째 줄에 있는지 찾습니다. nginx -T 는 include 된 파일을 모두 합쳐 찍고, 파일마다 # configuration file 줄을 붙입니다.

console
$ sudo nginx -T 2>/dev/null | grep -nE "^# configuration file|server_name"
output
189:# configuration file /etc/nginx/sites-enabled/default:235:	server_name _;272:#	server_name example.com;282:# configuration file /etc/nginx/sites-enabled/example.com:285:    server_name example.com;289:# configuration file /etc/nginx/sites-enabled/example.com.bak:292:    server_name example.com;

# 으로 시작하는 줄(272행)은 주석이라 충돌과 상관없습니다. 이 결과에서는 example.com 과 example.com.bak 두 파일이 같은 이름을 갖고 있습니다.

[4] Ubuntu 라면 sites-enabled/ 에 남은 사본을 봅니다. 패키지의 nginx.conf 는 두 폴더를 다르게 읽습니다.

output
59:	include /etc/nginx/conf.d/*.conf;60:	include /etc/nginx/sites-enabled/*;

conf.d 는 .conf 로 끝나는 파일만 읽지만 sites-enabled 는 모든 파일을 읽습니다. 그래서 편집 전에 만든 example.com.bak, example.com~, example.com.orig 같은 사본이 그대로 설정이 됩니다.

console
$ ls -l /etc/nginx/sites-enabled/
output
lrwxrwxrwx 1 root root 34 … default -> /etc/nginx/sites-available/defaultlrwxrwxrwx 1 root root 38 … example.com -> /etc/nginx/sites-available/example.com-rw-r--r-- 1 root root 86 … example.com.bak

sites-enabled 의 정상 항목은 sites-available 을 가리키는 링크(->)입니다. 링크가 아닌 일반 파일이 있으면 의심합니다.

[5] 사본을 sites-enabled 밖으로 옮깁니다. 지우지 말고 옮겨 두면 되돌릴 수 있습니다.

console
$ sudo mv /etc/nginx/sites-enabled/example.com.bak /root/$ sudo nginx -t
output
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

경고가 사라졌으면 sudo systemctl reload nginx 로 반영합니다. 되돌리려면 같은 파일을 다시 sites-enabled/ 로 옮기고 검사·reload 합니다.

[6] 사본이 아니라 일부러 나눈 설정이면 한쪽으로 합칩니다. 같은 이름을 conf.d/ 와 sites-enabled/ 양쪽에 둔 경우, 또는 두 사이트 파일에 같은 별칭(www. 등)을 넣은 경우입니다. 이름은 한 블록에만 남기고, 다른 블록에서는 그 이름을 server_name 줄에서 뺍니다. 기본 서버로 받으려는 목적이었다면 이름을 겹치지 말고 listen 80 default_server; 를 씁니다.

긴 이름 때문에 시작이 실패하는 경우는 could not build server_names_hash, 포트를 잡지 못하는 경우는 bind() Address already in use를 봅니다.

Nginx 로그를 브라우저에서 바로 분석 ↗ — 아무것도 올라가지 않습니다.

#nginx#server_name#conflicting-server-name#sites-enabled