httpd.conf defaults for unspecified requests
I run a couple of sites at home with the help of OpenBSD 6.5, httpd and letsencrypt. Situation: one.example.com and two.example.com both resolve to 192.0.2.1.
httpd.conf:
myip = "192.0.2.1"
server "default" {
listen on $myip port 80
block return 403
}
server "one.example.com" {
listen on $myip port 80
root "/htdocs/one.example.com"
}
server "two.example.com" {
listen on $myip port 80
block return 301 "https://two.example.com$REQUEST_URI"
location "/.well-known/acme-challenge/*" {
pass
root "/acme"
request strip 2
}
}
server "two.example.com" {
listen on $myip tls port 443
root "/htdocs/two.example.com"
tls {
certificate "/etc/ssl/two.example.com.pem"
key "/etc/ssl/private/two.example.com.key"
}
}
When i go to http://192.0.2.1 i get served a 403 (default block). http://one.example.com serves its content correctly and so does http://two.example.com after redirecting me to https.
Next, when i go to https://192.0.2.1 i end up on https://two.example.com along with certificate warning. https://one.example.com also sends me to https://two.example.com. This is probably because it's the first tls block in my config? So how do i counter this correctly?
I tried putting a second "default" server block at the top of the config (see below) but it appears to require a tls {} part along with a certificate otherwise httpd won't respond to anything at all (even though it does start). I could add a self signed cert to make it work but i'm starting to wonder if i'm still on the right path here. I just want unspecified requests to be dropped or returned 403 (and not "leak" vhosts running on my ip because of how it selects what to serve by default). Any advice is appreciated.
server "default" {
listen on $myip tls port 443
block return 403
}
Posted Sep 28, 2019, 2:52 AM UTC
I only see one tls block in your supplied config.
Added: Does httpd support SNI yet?
Added2: Yes, apparently httpd supports SNI.
And my understanding is that
relaydwill support SNI in the next release (already in -CURRENT). Very much looking forward to this.edit: added link/citation
Correct, only one of the vhosts serves tls, the other should not respond to it.