mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 22:40:31 -05:00
errors: Fix file paths for error pages & empty log filenames
This commit is contained in:
parent
78e6d7db95
commit
9b74901b40
1 changed files with 3 additions and 1 deletions
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue