Commit 9b74901b authored by Matthew Holt's avatar Matthew Holt

errors: Fix file paths for error pages & empty log filenames

parent 78e6d7db
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"path"
"strconv" "strconv"
"github.com/mholt/caddy/middleware" "github.com/mholt/caddy/middleware"
...@@ -28,7 +29,7 @@ func New(c middleware.Controller) (middleware.Middleware, error) { ...@@ -28,7 +29,7 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
file = os.Stdout file = os.Stdout
} else if handler.LogFile == "stderr" { } else if handler.LogFile == "stderr" {
file = os.Stderr file = os.Stderr
} else { } else if handler.LogFile != "" {
file, err = os.OpenFile(handler.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) file, err = os.OpenFile(handler.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil { if err != nil {
return err return err
...@@ -131,6 +132,7 @@ func parse(c middleware.Controller) (ErrorHandler, error) { ...@@ -131,6 +132,7 @@ func parse(c middleware.Controller) (ErrorHandler, error) {
handler.LogFile = where handler.LogFile = where
} else { } else {
// Error page; ensure it exists // Error page; ensure it exists
where = path.Join(c.Root(), where)
f, err := os.Open(where) f, err := os.Open(where)
if err != nil { if err != nil {
return hadBlock, c.Err("Unable to open error page '" + where + "': " + err.Error()) return hadBlock, c.Err("Unable to open error page '" + where + "': " + err.Error())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment