Skip to content

Commit

Permalink
X-Forwarder-For, print backend connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cthom06 committed Nov 3, 2010
1 parent da628f4 commit 551f4ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ func (s Server) ServeHTTP(out http.ResponseWriter, r *http.Request) {
oc.Close()
}()
go func() {
r.Header["X-Forwarded-For"] = out.RemoteAddr()
r.Write(c)
io.Copy(c, oc)
c.Close()
}()
return
} else c.Close()
}
} else os.Stderr.WriteString(os.Args[0] + ": " + e.String() + "\n")
}
out.WriteHeader(503)
out.Write([]byte("Service Unavailable"))
Expand All @@ -50,6 +51,6 @@ func main() {
}
}
}
os.Stderr.WriteString(e.String() + "\n")
os.Stderr.WriteString(os.Args[0] + ": " + e.String() + "\n")
os.Exit(1)
}

0 comments on commit 551f4ae

Please sign in to comment.