config
cp /etc/examples/httpd.conf /etc
Simple config that redirects non-www traffic to www.
server "www.example.com" {
listen on * port 80
root "/htdocs/www.example.com"
}
server "example.com" {
listen on * port 80
block return 301 "http://www.example.com$REQUEST_URI"
}
# Include additional MIME types
types {
include "/usr/share/misc/mime.types"
}
The httpd server is chrooted to /var/www/
so the document root should be in
that directory or deeper.
verify config
httpd -n
ssl redirects
Instead of adding a redirect for each server block you can add a single one to cover them all.
server "secure-redirect" {
listen on egress port 80 block return 301 "https://$HTTP_HOST$REQUEST_URI"
}