summaryrefslogtreecommitdiffhomepage
path: root/middleware/errors
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2015-04-28 13:05:01 -0600
committerMatthew Holt <[email protected]>2015-04-28 13:05:01 -0600
commit9b74901b40d0b1f2bafceceaf98174252d8208d4 (patch)
tree290c960de5458ecd5d7e049792eae5ccec32ea6b /middleware/errors
parent78e6d7db95db8ba7862b29c2ce467da046be92c8 (diff)
downloadcaddy-9b74901b40d0b1f2bafceceaf98174252d8208d4.tar.gz
caddy-9b74901b40d0b1f2bafceceaf98174252d8208d4.zip
errors: Fix file paths for error pages & empty log filenames
Diffstat (limited to 'middleware/errors')
-rw-r--r--middleware/errors/errors.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/middleware/errors/errors.go b/middleware/errors/errors.go
index d89a95fde..36c7c5d72 100644
--- a/middleware/errors/errors.go
+++ b/middleware/errors/errors.go
@@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
+ "path"
"strconv"
"github.com/mholt/caddy/middleware"
@@ -28,7 +29,7 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
file = os.Stdout
} else if handler.LogFile == "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)
if err != nil {
return err
@@ -131,6 +132,7 @@ func parse(c middleware.Controller) (ErrorHandler, error) {
handler.LogFile = where
} else {
// Error page; ensure it exists
+ where = path.Join(c.Root(), where)
f, err := os.Open(where)
if err != nil {
return hadBlock, c.Err("Unable to open error page '" + where + "': " + err.Error())