The HTTP status code for a web server's default “hello” front page
utcc.utoronto.ca
utcc.utoronto.ca
On the other hand, if there's no page to be served, not even a default one, then it should 404. (Unless the default config is to list the (empty) directory, and it exists, in which case 200.)
There's no need to complicate things beyond that. One thing that I've learned over many years of experience with software is that if at all possible you should never add additional conditions or edge-cases, because they will tend to create more problems than they solve. The server is behaving most consistently if it treats the placeholder page the same as any other.
Would you want a compiler that specifically detects "hello world" programs and compiles them to always return failure, under the similar argument that it's not a "real" program? Because that's the logical conclusion of this sort of inane overthinking.
No code is faster than no code
205 Temporary Placeholder
or something along those lines?From a user perspective, getting a 404 after following a link that previously worked can indicate a couple of things. Like maybe the resource still exists in some other place, but they didn't set up redirects. Maybe it's been "privated" in some way, and I no longer have access to it.
A 410 makes it explicitly clear to me, that the resource has been permanently deleted. It'd also be nice if the response included some metadata as to when the resource was deleted.
5xx is a failure to serve the page, which is not the case if a placeholder is served
5xx still returns content. 5xx can return HTML content. Browser will display it properly.
4xx codes mean client error. 5xx codes mean server error. Server misconfiguration is a server error. Client did nothing wrong.
You can serve a body with a 404, user will see the appropriate message and robot can safely ignore this page until further notice. Search engine will often retry 404 later and slowly reduce crawling if it stays not found.
I mean, the real point is here : nobody cares what your server is answering just after being setup. However I can see how it’s a problem if for any reason, a server loses its configuration and still acts like everything is fine.
(ofc you can bypass this by monitoring a more specific url but it’s not always possible if you are not the one deciding what the server serves)
For your analogy, it’s more like you’d want your compiler to fail if you fed it with no source code.
I kept hitting an issue where random things on the internet would stop working: USPS's login page, my WiFi garage door opener, etc.
I finally tracked the problem down to bright cloud flagging my home IP as a "proxy". We went back and forth for a while, and the one thing they eventually showed me was a number of subdomains for things I no longer had online (such as a gitlab instance), that now got the default Nginx Proxy Manager "success" page. (I have a wildcard subdomain set up, so it continues to resolve even after I take something down.)
It turns out that brightcloud's crawler just flags any page with the word "proxy" on it - it doesn't distinguish between a reverse proxy and the open forward proxies that their customers actually care about.
I switched the configuration to serve up a 404 for unrecognized domains/subdomains and haven't had a problem since.
This is a subtle but important distinction…
There are so many layers now between a user and the application code. What if due to some misconfiguration or new image push or ___ the web server or load balancer or PaaS router or CDN or Cloudflare or whatever starts serving some default placeholder, or error message, or its own content up on my URL?
That’s why I’d argue for a non-200 status code for the default “hello” page.
And in production monitoring I’d use something like https://heiioncall.com/blog/enhanced-api-monitoring-with-exp... to verify the presence of some special header set only by your application, so you know that your desired code is actually being called. (In addition to asserting the HTTP status code.)
That's all you need to know. HTTP, like the other components of the web stack, is an organically grown monstrosity that resembles what you would get if a thousand random people shat on a pile. Any attempt to extract philosophical purity and/or rigorous discussion from it is a massive waste of time. Just use what you feel makes sense at the current moment, and move on.
[0] https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418
What about "518 - teapot not configured" ?
When I launch a container that's supposed to sit in front of multiple other containers as a reverse proxy or just serve static files, I need to know whether the Apache process in it is working and actually serving files. This is regardless of the rest of the configuration and whether every site is up: for example, if 19 out of 20 sites are configured correctly and are served, the failing one can be addressed separately later.
In my case, that's as easy as the following:
healthcheck:
test: "curl http://127.0.0.1:80 | grep 'Apache2 is up and running' || exit 1"
interval: 10s
timeout: 10s
retries: 6
start_period: 5s
(there are also separate external uptime checks for the actual sites with domains and HTTPS, too)I serve some HTML files by default in every container with specific contents, in addition to any domains that the web server has configured. If I can access these default files, that means that the web server is up and I can then think about testing the rest of the configuration myself. In this case, I decided to check the file contents instead of the status code.
Frankly, you can get the same result with just status codes (probably a 200 IMO because of how simple it is), or maybe some specific HTML contents in the default page to identify whether you're talking to the correct web server instance and have deployed it in the right place, maybe even page contents that have been generated by something like PHP-FPM to check whether scripts get executed correctly (also like testing OpenResty with Lua) if you need that sort of thing.
Whatever works for you.
Proposal: 209 Healthy With Minimum Configuration
Seems to fit that bill well. Though I'm not sure exactly what your browser would show as it's meant not to cause a direct to a new page.
Give no information about what it is.
Give a status to a monitor that it is alive.
They started out as server response codes but once people started making web applications and APIs they started overloading the server response codes to also have meaning as application response codes, making things even more confusing.
Not Implemented is supposed to mean that the server does not implement the request verb (PUT, PATCH, DELETE, POST, etc.), not really relevant to anything that might exist or be running on the server.
Maybe there could've been a separate standard header for application status, but that might not be great either since everything would have to handle all combinations of server and app status.