mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-24 09:37:03 +01: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"
|
"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) {
|
||||||
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) {
|
||||||
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())
|
||||||
|
|
Loading…
Reference in a new issue