I'm new to Nginx, which I'm running in a Docker container to serve a simple website. I want to add an /health
endpoint that simply returns status 200 + some arbitrary content.
I copied and adjusted the standard nginx.conf
from /etc/nginx/
by adding
server {
location /health {
return 200 "alive";
}
}
at the bottom inside the http
block. But when I run the Docker, and try to access localhost/health
, I just get no such file or directory
. Accessing the website at localhost
works fine.
I also tried copying other code blocks, e.g., this one: https://gist.github.com/dhrrgn/8650077
But then I get conflicting server name "" on 0.0.0.0:80, ignored nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
.
Am I placing the location
at a wrong location inside nginx.conf
? Do I need some special server configuration? What's the problem?