【发布时间】:2018-05-11 15:30:32
【问题描述】:
我是 Nginx 的新手,我在 Docker 容器中运行它以服务于一个简单的网站。我想添加一个 /health 端点,它只返回状态 200 + 一些任意内容。
我从/etc/nginx/复制并调整了标准nginx.conf添加
server {
location /health {
return 200 "alive";
}
}
在http 块内的底部。但是当我运行 Docker 并尝试访问 localhost/health 时,我得到了 no such file or directory。访问localhost 的网站可以正常工作。
我还尝试复制其他代码块,例如,这个:https://gist.github.com/dhrrgn/8650077
但后来我得到conflicting server name "" on 0.0.0.0:80, ignored nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored。
我是否将location 放置在nginx.conf 内的错误位置?我需要一些特殊的服务器配置吗?有什么问题?
【问题讨论】: