I was surprised that `server "default"` didn't act like I expected. In this
example I expected `test1` to get 200 and everything else to get 404 but
this is not the case. In this example server "test1" actually catches all:
localhost, test1, and test2 will get code 200.

/etc/hosts:
127.0.0.1  localhost  test1  test2

/tmp/httpd.conf:
server "test1" {
  listen on localhost port 8080
  block return 200
}

server "default" {
  listen on localhost port 8080
  block return 404
}

httpd -df /tmp/httpd.conf &

ftp -o - http://localhost:8080/ #200
ftp -o - http://test1:8080/ #200
ftp -o - http://test2:8080/ #200

man httpd.conf says:
"Match the server name using shell globbing rules. This can be an explicit
name, www.example.com, or a name including wildcards, *.example.com."

There is no mention as to what `server "default"` does even though it is
used several times in the man page. I find the behaviour to be odd
for it not to be documented. It isn't until I change the line to `server
"*"` when it starts doing what I expected:

ftp -o- http://localhost:8080/ #404
ftp -o- http://test1:8080/ #200
ftp -o- http://test2:8080/ #404

This is a gotcha in general. I would think the examples should use server
"*" instead and document what server "default" actually does.

and while we are here. Why does running httpd as a user say:
httpd: need root privileges

does it...?

-alfred

Reply via email to