nginx: [emerg] host not found in upstream
[nginx]
nginxでproxy設定時に発生したエラーの対処めも
バーチャルホストに振り分けるため以下の様に設定していた。
test.comはすべて同一サーバ。
- nginx.conf
} server { listen 80; server_name a.test.com; location / { proxy_pass http://a.local; } } server { listen 80; server_name b.test.com; location / { proxy_pass http://b.local; } } server { listen 80; server_name c.test.com; location / { proxy_pass http://c.local; } }
proxy設定した後にconfigtestをしたら以下のメッセージが出た。
# /etc/init.d/nginx configtest nginx: [emerg] host not found in upstream "c.local" in /etc/nginx/nginx.conf:99 nginx: configuration file /etc/nginx/nginx.conf test failed
upstream?
/etc/hostsに登録したことを思い出したので見てみる
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.xxx.xxx a.local b.local c.lcal
"c.local"がタイポして"c.lcal"になっていた
ここをnginxで指定しているように"c.local"に直して再度configtest
# /etc/init.d/nginx configtest nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
うまくいったようだ。
nginxはconf内の文法チェックだけでなく名前解決などもチェックしてるみたいだ。